class Cabin::Metrics::Meter

Public Class Methods

new() click to toggle source

A new Meter

Counters can be incremented and decremented only by 1 at a time..

# File lib/cabin/metrics/meter.rb, line 12
def initialize
  @inspectables = [ :@value ]
  @value = 0
  @lock = Mutex.new
end

Public Instance Methods

mark() click to toggle source

Mark an event

# 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() click to toggle source
# File lib/cabin/metrics/meter.rb, line 34
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/meter.rb, line 29
def value
  return @lock.synchronize { @value }
end