lib/sapience/appender/datadog.rb in sapience-0.1.8 vs lib/sapience/appender/datadog.rb in sapience-0.1.9
- old
+ new
@@ -62,11 +62,17 @@
end
end
true
end
- def timing(metric, duration)
- provider.timing(metric, duration)
+ def timing(metric, duration = 0)
+ if block_given?
+ start = Time.now
+ yield
+ provider.timing(metric, ((Time.now - start)*1000).floor)
+ else
+ provider.timing(metric, duration)
+ end
end
def increment(metric, amount = 1)
provider.batch do
amount.times { provider.increment(metric) }