class Cabin::Metrics::Counter
Public Class Methods
new()
click to toggle source
A new Counter.
Counters can be incremented and decremented only by 1 at a time..
# File lib/cabin/metrics/counter.rb, line 12 def initialize @inspectables = [ :@value ] @value = 0 @lock = Mutex.new end
Public Instance Methods
decr()
click to toggle source
decrement this counter
# File lib/cabin/metrics/counter.rb, line 25 def decr @lock.synchronize { @value -= 1 } emit end
incr()
click to toggle source
increment this counter
# File lib/cabin/metrics/counter.rb, line 19 def incr @lock.synchronize { @value += 1 } emit end
to_hash()
click to toggle source
# File lib/cabin/metrics/counter.rb, line 37 def to_hash return @lock.synchronize do { :value => @value } end end
value()
click to toggle source
Get the value of this metric.
# File lib/cabin/metrics/counter.rb, line 32 def value return @lock.synchronize { @value } end