lib/instrumental/agent.rb in instrumental_agent-0.8.0 vs lib/instrumental/agent.rb in instrumental_agent-0.8.1

- old
+ new

@@ -100,13 +100,16 @@ # agent.time('find_time_per_post', 1 / ids.size.to_f) do # Post.find(ids) # end def time(metric, multiplier = 1) start = Time.now - result = yield - finish = Time.now - duration = finish - start - gauge(metric, duration * multiplier, start) + begin + result = yield + ensure + finish = Time.now + duration = finish - start + gauge(metric, duration * multiplier, start) + end result end # Calls time and changes durations into milliseconds. def time_ms(metric, &block)