com.twitter.common.stats
Class SlidingStats

java.lang.Object
  extended by com.twitter.common.stats.SlidingStats

public class SlidingStats
extends Object

Tracks event statistics over a sliding window of time. An event is something that has a frequency and associated total.


Constructor Summary
SlidingStats(String name, String totalUnitDisplay)
          Creates a new sliding statistic with the given name
SlidingStats(String name, String totalUnitDisplay, int windowSize)
          Creates a new sliding statistic with the given name
 
Method Summary
 void accumulate(long value)
          Accumulates counter by an offset.
 AtomicLong getEventCounter()
           
 Stat<Double> getPerEventLatency()
           
 AtomicLong getTotalCounter()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SlidingStats

public SlidingStats(String name,
                    String totalUnitDisplay)
Creates a new sliding statistic with the given name

Parameters:
name - Name for this stat collection.
totalUnitDisplay - String to display for the total counter unit.

SlidingStats

public SlidingStats(String name,
                    String totalUnitDisplay,
                    int windowSize)
Creates a new sliding statistic with the given name

Parameters:
name - Name for this stat collection.
totalUnitDisplay - String to display for the total counter unit.
windowSize - The window size for the per second Rate and Ratio stats.
Method Detail

getTotalCounter

public AtomicLong getTotalCounter()

getEventCounter

public AtomicLong getEventCounter()

getPerEventLatency

public Stat<Double> getPerEventLatency()

accumulate

public void accumulate(long value)
Accumulates counter by an offset. This is is useful for tracking things like latency of operations. TODO(William Farner): Implement a wrapper to SlidingStats that expects to accumulate time, and can convert between time units.

Parameters:
value - The value to accumulate.

toString

public String toString()
Overrides:
toString in class Object