From 834bd23a07a84ff631da1ded37c643a3a371cb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 24 Jul 2010 10:22:22 +0200 Subject: Get rid of instrumenter.elapsed. --- .../lib/active_support/notifications/instrumenter.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support/notifications/instrumenter.rb') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 713d5a5f25..441fefb491 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -9,30 +9,24 @@ module ActiveSupport def initialize(notifier) @id = unique_id @notifier = notifier - @started = nil - @finished = nil end # 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 def instrument(name, payload={}) + started = Time.now + begin - @started = Time.now yield rescue Exception => e payload[:exception] = [e.class.name, e.message] raise e ensure - @finished = Time.now - @notifier.publish(name, @started, @finished, @id, payload) + @notifier.publish(name, started, Time.now, @id, payload) end end - def elapsed - 1000.0 * (@finished.to_f - @started.to_f) - end - private def unique_id SecureRandom.hex(10) -- cgit v1.2.3