Class: Racecar::Instrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/racecar/instrumenter.rb

Overview

Common API for instrumentation to standardize namespace and default payload

Constant Summary collapse

NAMESPACE =
"racecar"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend:, default_payload: {}) ⇒ Instrumenter

Returns a new instance of Instrumenter.



12
13
14
15
# File 'lib/racecar/instrumenter.rb', line 12

def initialize(backend:, default_payload: {})
  @backend = backend
  @default_payload = default_payload
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



10
11
12
# File 'lib/racecar/instrumenter.rb', line 10

def backend
  @backend
end

Instance Method Details

#instrument(event_name, payload = {}, &block) ⇒ Object



17
18
19
# File 'lib/racecar/instrumenter.rb', line 17

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