Method: ActiveSupport::Notifications::Instrumenter#instrument
- Defined in:
- activesupport/lib/active_support/notifications/instrumenter.rb
#instrument(name, payload = {}) ⇒ Object
Given a block, instrument it by measuring the time taken to execute and publish it. Without a block, simply send a message via the notifier. Notice that events get sent even if an error occurs in the passed-in block.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 54 def instrument(name, payload = {}) handle = build_handle(name, payload) handle.start begin yield payload if block_given? rescue Exception => e payload[:exception] = [e.class.name, e.] payload[:exception_object] = e raise e ensure handle.finish end end |