Class: Cabin::Metrics::Meter
- Inherits:
-
Object
- Object
- Cabin::Metrics::Meter
- Includes:
- Cabin::Metric
- Defined in:
- lib/cabin/metrics/meter.rb
Instance Method Summary collapse
-
#initialize ⇒ Meter
constructor
A new instance of Meter.
-
#mark ⇒ Object
Mark an event.
- #to_hash ⇒ Object
- #value ⇒ Object
Methods included from Cabin::Metric
Methods included from Publisher
Methods included from Inspectable
Constructor Details
#initialize ⇒ Meter
Returns a new instance of Meter.
12 13 14 15 16 |
# File 'lib/cabin/metrics/meter.rb', line 12 def initialize @inspectables = [ :@value ] @value = 0 @lock = Mutex.new end |
Instance Method Details
#mark ⇒ Object
Mark an event
19 20 21 22 23 24 25 |
# File 'lib/cabin/metrics/meter.rb', line 19 def mark @lock.synchronize do @value += 1 # TODO(sissel): Keep some moving averages? end emit end |
#to_hash ⇒ Object
34 35 36 37 38 |
# File 'lib/cabin/metrics/meter.rb', line 34 def to_hash return @lock.synchronize do { :value => @value } end end |
#value ⇒ Object
29 30 31 |
# File 'lib/cabin/metrics/meter.rb', line 29 def value return @lock.synchronize { @value } end |