com.netflix.servo.monitor
Class StatsMonitor

java.lang.Object
  extended by com.netflix.servo.monitor.AbstractMonitor<java.lang.Long>
      extended by com.netflix.servo.monitor.StatsMonitor
All Implemented Interfaces:
CompositeMonitor<java.lang.Long>, Monitor<java.lang.Long>, NumericMonitor<java.lang.Long>
Direct Known Subclasses:
StatsTimer

public class StatsMonitor
extends AbstractMonitor<java.lang.Long>
implements CompositeMonitor<java.lang.Long>, NumericMonitor<java.lang.Long>

A Timer that provides statistics.

The statistics are collected periodically and are published according to the configuration specified by the user using a StatsConfig object.


Field Summary
protected  Counter count
           
protected static java.util.concurrent.ScheduledExecutorService defaultExecutor
           
protected  Counter totalMeasurement
           
 
Fields inherited from class com.netflix.servo.monitor.AbstractMonitor
config
 
Constructor Summary
StatsMonitor(MonitorConfig config, StatsConfig statsConfig, java.util.concurrent.ScheduledExecutorService executor, java.lang.String totalTagName, boolean autoStart, Tag... additionalTags)
          Creates a new instance of the timer with a unit of milliseconds, using the ScheduledExecutorService provided by the user.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 long getCount()
          Get the number of times this timer has been updated
 java.util.List<Monitor<?>> getMonitors()
          Returns a list of sub-monitors for this composite.
 long getTotalMeasurement()
          Get the total time recorded for this timer
 java.lang.Long getValue()
          Get the value of the measurement
protected  void handleException(java.lang.Exception e)
          This is called when we encounter an exception while processing the values recorded to compute the stats.
 int hashCode()
          
 void record(long measurement)
          Record the measurement we want to perform statistics on
 void startComputingStats()
          starts computation.
 java.lang.String toString()
          
 
Methods inherited from class com.netflix.servo.monitor.AbstractMonitor
getConfig
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.netflix.servo.monitor.Monitor
getConfig
 

Field Detail

defaultExecutor

protected static final java.util.concurrent.ScheduledExecutorService defaultExecutor

count

protected final Counter count

totalMeasurement

protected final Counter totalMeasurement
Constructor Detail

StatsMonitor

public StatsMonitor(MonitorConfig config,
                    StatsConfig statsConfig,
                    java.util.concurrent.ScheduledExecutorService executor,
                    java.lang.String totalTagName,
                    boolean autoStart,
                    Tag... additionalTags)
Creates a new instance of the timer with a unit of milliseconds, using the ScheduledExecutorService provided by the user.

Method Detail

startComputingStats

public void startComputingStats()
starts computation. Because of potential race conditions, derived classes may wish to define initial state before calling this function which starts the executor


getMonitors

public java.util.List<Monitor<?>> getMonitors()
Returns a list of sub-monitors for this composite.

Specified by:
getMonitors in interface CompositeMonitor<java.lang.Long>

record

public void record(long measurement)
Record the measurement we want to perform statistics on


getValue

public java.lang.Long getValue()
Get the value of the measurement

Specified by:
getValue in interface Monitor<java.lang.Long>

handleException

protected void handleException(java.lang.Exception e)
This is called when we encounter an exception while processing the values recorded to compute the stats.

Parameters:
e - Exception encountered.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

getCount

public long getCount()
Get the number of times this timer has been updated


getTotalMeasurement

public long getTotalMeasurement()
Get the total time recorded for this timer