Class: Kafka::Instrumenter
- Inherits:
-
Object
- Object
- Kafka::Instrumenter
- Defined in:
- lib/kafka/instrumenter.rb
Constant Summary collapse
- NAMESPACE =
"kafka"
Instance Method Summary collapse
-
#initialize(default_payload = {}) ⇒ Instrumenter
constructor
A new instance of Instrumenter.
- #instrument(event_name, payload = {}, &block) ⇒ Object
Constructor Details
#initialize(default_payload = {}) ⇒ Instrumenter
Returns a new instance of Instrumenter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/kafka/instrumenter.rb', line 7 def initialize(default_payload = {}) @default_payload = default_payload if defined?(ActiveSupport::Notifications) @backend = ActiveSupport::Notifications else @backend = nil end end |
Instance Method Details
#instrument(event_name, payload = {}, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/kafka/instrumenter.rb', line 17 def instrument(event_name, payload = {}, &block) if @backend payload.update(@default_payload) @backend.instrument("#{event_name}.#{NAMESPACE}", payload, &block) else block.call(payload) if block end end |