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
decrement this counter
# File lib/cabin/metrics/counter.rb, line 25 def decr @lock.synchronize { @value -= 1 } emit end
increment this counter
# File lib/cabin/metrics/counter.rb, line 19 def incr @lock.synchronize { @value += 1 } emit end
# File lib/cabin/metrics/counter.rb, line 37 def to_hash return @lock.synchronize do { :value => @value } end end
Get the value of this metric.
# File lib/cabin/metrics/counter.rb, line 32 def value return @lock.synchronize { @value } end