Sha256: c8df8cc03cbf09856389621d5ee0dfda12e15a02a206c896a2ce6d185e1ce0b4

Contents?: true

Size: 724 Bytes

Versions: 21

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

module InstrumentAllTheThings
  module Instrumentors
    DEFAULT_EXECUTION_COUNT_AND_TIMING_OPTIONS = {}.freeze

    EXECUTION_COUNT_AND_TIMING_WRAPPER = proc do |_opts, context|
      proc do |klass, next_blk, actual_code|
        context.tags ||= []

        InstrumentAllTheThings.increment("#{context.stats_name(klass)}.executed", { tags: context.tags })
        InstrumentAllTheThings.time("#{context.stats_name(klass)}.duration", { tags: context.tags }) do
          next_blk.call(klass, actual_code)
        end
      rescue StandardError
        InstrumentAllTheThings.increment("#{context.stats_name(klass)}.errored", { tags: context.tags })
        raise
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
instrument_all_the_things-5.0.1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-5.0.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.4.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-4.0.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.1.2 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.1.2.pre1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.1.1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.1.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.1.0.pre1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.0.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-3.0.0.pre1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-2.0.2 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-2.0.1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-2.0.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.3.1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.3.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.2.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.1.1 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.1.0 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb
instrument_all_the_things-1.0.4 lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb