public class StatsMonitor extends AbstractMonitor<java.lang.Long> implements CompositeMonitor<java.lang.Long>, NumericMonitor<java.lang.Long>
Timer
that provides statistics.
The statistics are collected periodically and are published according to the configuration
specified by the user using a StatsConfig
object.Modifier and Type | Field and Description |
---|---|
protected Counter |
count |
protected static java.util.concurrent.ScheduledExecutorService |
defaultExecutor |
protected Counter |
totalMeasurement |
config
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
long |
getCount(int pollerIndex)
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()
Returns the current value for the monitor for the default polling interval.
|
java.lang.Long |
getValue(int pollerIndex)
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() |
getConfig
protected static final java.util.concurrent.ScheduledExecutorService defaultExecutor
protected final Counter count
protected final Counter totalMeasurement
public StatsMonitor(MonitorConfig config, StatsConfig statsConfig, java.util.concurrent.ScheduledExecutorService executor, java.lang.String totalTagName, boolean autoStart, Tag... additionalTags)
ScheduledExecutorService
provided by the user.public void startComputingStats()
public java.util.List<Monitor<?>> getMonitors()
getMonitors
in interface CompositeMonitor<java.lang.Long>
public void record(long measurement)
public java.lang.Long getValue(int pollerIndex)
public java.lang.Long getValue()
AbstractMonitor
getValue
in interface Monitor<java.lang.Long>
getValue
in class AbstractMonitor<java.lang.Long>
protected void handleException(java.lang.Exception e)
e
- Exception encountered.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public long getCount(int pollerIndex)
public long getTotalMeasurement()