aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications/instrumenter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/notifications/instrumenter.rb')
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb
index 0655dd0cb6..f3d877efe7 100644
--- a/activesupport/lib/active_support/notifications/instrumenter.rb
+++ b/activesupport/lib/active_support/notifications/instrumenter.rb
@@ -4,16 +4,20 @@ require 'active_support/core_ext/module/delegation'
module ActiveSupport
module Notifications
class Instrumenter
+ attr_reader :id
+
def initialize(notifier)
@id = unique_id
@notifier = notifier
end
+ # Instrument the given block by measuring the time taken to execute it
+ # and publish it.
def instrument(name, payload={})
time = Time.now
- yield if block_given?
- ensure
+ result = yield(payload) if block_given?
@notifier.publish(name, time, Time.now, @id, payload)
+ result
end
private