Class: ActiveSupport::Notifications::Instrumenter
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/notifications/instrumenter.rb |
Overview
Instrumenters are stored in a thread local.
Class Method Summary
- .new(notifier) ⇒ Instrumenter constructor
Instance Attribute Summary
- #id readonly
Instance Method Summary
-
#finish(name, payload)
Send a finish notification with
name
andpayload
. - #finish_with_state(listeners_state, name, payload)
-
#instrument(name, payload = {})
Instrument the given block by measuring the time taken to execute it and publish it.
-
#start(name, payload)
Send a start notification with
name
andpayload
.
Constructor Details
.new(notifier) ⇒ Instrumenter
Instance Attribute Details
#id (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 9
attr_reader :id
Instance Method Details
#finish(name, payload)
Send a finish notification with name
and payload
.
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 39
def finish(name, payload) @notifier.finish name, @id, payload end
#finish_with_state(listeners_state, name, payload)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 43
def finish_with_state(listeners_state, name, payload) @notifier.finish name, @id, payload, listeners_state end
#instrument(name, payload = {})
Instrument the given block by measuring the time taken to execute it and publish it. Notice that events get sent even if an error occurs in the passed-in block.
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 19
def instrument(name, payload = {}) # some of the listeners might have state listeners_state = start name, payload begin yield payload rescue Exception => e payload[:exception] = [e.class.name, e. ] payload[:exception_object] = e raise e ensure finish_with_state listeners_state, name, payload end end
#start(name, payload)
Send a start notification with name
and payload
.
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 34
def start(name, payload) @notifier.start name, @id, payload end