Class: Racecar::Instrumenter
- Inherits:
-
Object
- Object
- Racecar::Instrumenter
- 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
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
Instance Method Summary collapse
-
#initialize(backend:, default_payload: {}) ⇒ Instrumenter
constructor
A new instance of Instrumenter.
- #instrument(event_name, payload = {}, &block) ⇒ Object
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
#backend ⇒ Object (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 |