aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/notifications.rb')
-rw-r--r--activesupport/lib/active_support/notifications.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb
index 886d7183eb..d65431a943 100644
--- a/activesupport/lib/active_support/notifications.rb
+++ b/activesupport/lib/active_support/notifications.rb
@@ -47,11 +47,21 @@ module ActiveSupport
attr_writer :notifier
delegate :publish, :unsubscribe, :to => :notifier
- def instrument(name, payload = {})
+ def instrument(name, payload = {}, info = nil)
if @instrumenters[name]
- instrumenter.instrument(name, payload) { yield payload if block_given? }
+ instrumenter.instrument(name, payload, info) {
+ yield payload if block_given?
+ }
else
- yield payload if block_given?
+ value = nil
+ if block_given?
+ if info
+ info[:elapsed] = Benchmark.ms { value = yield payload }
+ else
+ value = yield payload
+ end
+ end
+ value
end
end