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 Cabin::Metric

#emit, #instance, #instance=

Methods included from Publisher

#channel, #channel=, #publish

Methods included from Inspectable

#inspect

Constructor Details

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

Instance Method Details

#time(&block) ⇒ Object


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

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