Sha256: d4ff9919223884620883190c0633b87862dd671fedc5fbab9abf4cce4e133c2d

Contents?: true

Size: 583 Bytes

Versions: 6

Compression:

Stored size: 583 Bytes

Contents

module Racecar
  ##
  # Common API for instrumentation to standardize
  # namespace and default payload
  #
  class Instrumenter
    NAMESPACE = "racecar"
    attr_reader :backend

    def initialize(default_payload = {})
      @default_payload = default_payload

      @backend = if defined?(ActiveSupport::Notifications)
        ActiveSupport::Notifications
      else
        NullInstrumenter
      end
    end

    def instrument(event_name, payload = {}, &block)
      @backend.instrument("#{event_name}.#{NAMESPACE}", @default_payload.merge(payload), &block)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
racecar-2.0.0 lib/racecar/instrumenter.rb
racecar-2.0.0.beta6 lib/racecar/instrumenter.rb
racecar-2.0.0.beta5 lib/racecar/instrumenter.rb
racecar-2.0.0.beta4 lib/racecar/instrumenter.rb
racecar-2.0.0.beta3 lib/racecar/instrumenter.rb
racecar-2.0.0.beta2 lib/racecar/instrumenter.rb