Module: Phobos::Instrumentation

Included in:
Actions::ProcessBatch, Executor, Listener, Processor
Defined in:
lib/phobos/instrumentation.rb

Constant Summary collapse

NAMESPACE =
'phobos'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.subscribe(event) ⇒ Object



9
10
11
12
13
# File 'lib/phobos/instrumentation.rb', line 9

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



15
16
17
# File 'lib/phobos/instrumentation.rb', line 15

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

Instance Method Details

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



19
20
21
22
23
# File 'lib/phobos/instrumentation.rb', line 19

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