Module: Phobos::Instrumentation
- Included in:
- Actions::ProcessBatch, Actions::ProcessMessage, Executor, Listener
- 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
5 6 7 8 9 |
# File 'lib/phobos/instrumentation.rb', line 5 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
11 12 13 |
# File 'lib/phobos/instrumentation.rb', line 11 def self.unsubscribe(subscriber) ActiveSupport::Notifications.unsubscribe(subscriber) end |
Instance Method Details
#instrument(event, extra = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/phobos/instrumentation.rb', line 15 def instrument(event, extra = {}) ActiveSupport::Notifications.instrument("#{NAMESPACE}.#{event}", extra) do |extra| yield(extra) if block_given? end end |
#measure ⇒ Object
21 22 23 24 25 |
# File 'lib/phobos/instrumentation.rb', line 21 def measure start = Time.now.utc yield if block_given? (Time.now.utc - start).round(3) end |