Class: Cabin::Metrics::Timer

Inherits:
Histogram show all
Defined in:
lib/cabin/metrics/timer.rb

Defined Under Namespace

Classes: TimerContext

Instance Method Summary collapse

Methods inherited from Histogram

#initialize, #record, #to_hash, #value

Methods included from Inspectable

#inspect

Constructor Details

This class inherits a constructor from Cabin::Metrics::Histogram

Instance Method Details

#time(&block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/cabin/metrics/timer.rb', line 13

def time(&block)
  return time_block(&block) if block_given?

  # Return an object we can .stop
  # Call record(...) when we stop.
  return TimerContext.new { |duration| record(duration) }
end