Module: Messaging::Instrumentation

Included in:
Adapters::Kafka::Consumer, ConsumerSupervisor
Defined in:
lib/messaging/instrumentation.rb

Constant Summary collapse

NAMESPACE =
'messaging'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.subscribe(event) ⇒ Object



11
12
13
14
15
# File 'lib/messaging/instrumentation.rb', line 11

def self.subscribe(event)
  ActiveSupport::Notifications.subscribe("#{NAMESPACE}.#{event}") do |*args|
    yield ActiveSupport::Notifications::Event.new(*args) if block_given?
  end
end

.unsubscribe(subscriber) ⇒ Object



17
18
19
# File 'lib/messaging/instrumentation.rb', line 17

def self.unsubscribe(subscriber)
  ActiveSupport::Notifications.unsubscribe(subscriber)
end

Instance Method Details

#instrument(event, extra = {}) ⇒ Object



5
6
7
8
9
# File 'lib/messaging/instrumentation.rb', line 5

def instrument(event, extra = {})
  ActiveSupport::Notifications.instrument("#{NAMESPACE}.#{event}", extra) do |extra|
    yield(extra) if block_given?
  end
end