Method: Datadog::Statsd#time
- Defined in:
- lib/datadog/statsd.rb
#time(stat, opts = EMPTY_OPTIONS) { ... } ⇒ Object
Reports execution time of the provided block using #timing.
If the block fails, the stat is still reported, then the error is reraised
328 329 330 331 332 333 334 |
# File 'lib/datadog/statsd.rb', line 328 def time(stat, opts = EMPTY_OPTIONS) opts = { sample_rate: opts } if opts.is_a?(Numeric) start = now yield ensure timing(stat, ((now - start) * 1000).round, opts) end |