public class TimeStampedCounter extends com.codahale.metrics.Counter implements TimeStampedMetric
Counter class that provides an association
of the Counter value with time stamps.| Constructor and Description |
|---|
TimeStampedCounter(MetricRegistry registry,
CounterDescriptor descriptor)
Constructs a
TimeStampedCounter with the specified
characteristics using the specified MetricRegistry. |
TimeStampedCounter(MetricRegistry registry,
CounterDescriptor descriptor,
String uid)
Constructs a
TimeStampedCounter with the specified UID and other
characteristics using the specified MetricRegistry. |
| Modifier and Type | Method and Description |
|---|---|
void |
dec(long toSubtract) |
CounterDataPoint |
extractDataPoint()
Extract a
CounterDataPoint from this object. |
CounterDescriptor |
getDescriptor()
Gets the
MetricDescriptor that describes this TimeStampedMetric object. |
long |
getMsSpanned()
Determines the number of milliseconds spanned between the latest (update)
time stamp and the oldest (previous) time stamp, accounting for roll-over
of the time stamp.
|
long |
getPreviousTimeStamp()
Gets the previous time stamp.
|
protected TimeStampManager |
getTimeStampManager()
Gets the
TimeStampManager that this object uses to manage its
associated time stamps. |
String |
getUid()
Gets the UID.
|
long |
getUpdateTimeStamp()
Gets the update time stamp.
|
void |
inc(long toAdd) |
void |
reset()
Prepares the counter for use in a new time period by resetting its value
to zero and saving the most recent update time stamp as the previous time
stamp.
|
void |
setDescriptor(CounterDescriptor toSet)
Sets the
CounterDescriptor that specifies characteristics of this
TimeStampedCounter. |
void |
setPreviousTimeStamp(long time)
Sets the previous time stamp.
|
void |
setUid(String toSet)
Sets the UID of this object.
|
void |
setUpdateTimeStamp(long time)
Sets the update time stamp.
|
String |
toDebugString()
Gets a detailed representation of this object to facilitate debugging.
|
String |
toString() |
void |
updateTimeStamp()
Convenience method that sets the update time stamp to the current time.
|
public TimeStampedCounter(MetricRegistry registry, CounterDescriptor descriptor)
TimeStampedCounter with the specified
characteristics using the specified MetricRegistry.registry - MetricRegistry to use for allocating this objectdescriptor - CounterDescriptor that specifies various
characteristics of the resulting TimeStampedCounterpublic TimeStampedCounter(MetricRegistry registry, CounterDescriptor descriptor, String uid)
TimeStampedCounter with the specified UID and other
characteristics using the specified MetricRegistry.registry - MetricRegistry to use for allocating this objectdescriptor - CounterDescriptor that specifies various
characteristics of the resulting TimeStampedCounteruid - UID to assign to the resulting TimeStampedCounterIllegalArgumentException - if a null value is supplied for either
the CounterDescriptor or MetricRegistry argumentpublic void dec(long toSubtract)
dec in class com.codahale.metrics.Counterpublic CounterDataPoint extractDataPoint()
CounterDataPoint from this object.extractDataPoint in interface TimeStampedMetricCounterDataPointpublic CounterDescriptor getDescriptor()
TimeStampedMetricMetricDescriptor that describes this TimeStampedMetric object.getDescriptor in interface TimeStampedMetricMetricDescriptor that describes this TimeStampedMetricpublic long getMsSpanned()
TimeStampedMetricgetMsSpanned in interface TimeStampedMetricpublic long getPreviousTimeStamp()
TimeStampedMetricgetPreviousTimeStamp in interface TimeStampedMetricprotected TimeStampManager getTimeStampManager()
TimeStampManager that this object uses to manage its
associated time stamps.TimeStampManager for this objectpublic String getUid()
TimeStampedMetricgetUid in interface TimeStampedMetricpublic long getUpdateTimeStamp()
TimeStampedMetricgetUpdateTimeStamp in interface TimeStampedMetricpublic void inc(long toAdd)
inc in class com.codahale.metrics.Counterpublic void reset()
reset in interface TimeStampedMetricpublic void setDescriptor(CounterDescriptor toSet)
CounterDescriptor that specifies characteristics of this
TimeStampedCounter.toSet - the CounterDescriptor for this objectpublic void setPreviousTimeStamp(long time)
TimeStampedMetricsetPreviousTimeStamp in interface TimeStampedMetrictime - previous time stamppublic void setUid(String toSet)
TimeStampedMetricsetUid in interface TimeStampedMetrictoSet - new UID for this objectpublic void setUpdateTimeStamp(long time)
TimeStampedMetricsetUpdateTimeStamp in interface TimeStampedMetrictime - update time stamppublic String toDebugString()
public void updateTimeStamp()
TimeStampedMetricupdateTimeStamp in interface TimeStampedMetricCopyright © 2014. All Rights Reserved.