public class TimeStampedGauge extends Object implements com.codahale.metrics.Gauge<Long>, TimeStampedMetric
Gauge
interface that provides an
association of the Gauge
value with time stamps.Modifier and Type | Field and Description |
---|---|
static long |
UNINITIALIZED |
Constructor and Description |
---|
TimeStampedGauge(MetricRegistry registry,
GaugeDescriptor descriptor)
Constructs a
TimeStampedGauge with the specified characteristics
using the specified MetricRegistry . |
TimeStampedGauge(MetricRegistry registry,
GaugeDescriptor descriptor,
String uid)
Constructs a
TimeStampedGauge with the specified UID and other
characteristics using the specified MetricRegistry . |
Modifier and Type | Method and Description |
---|---|
GaugeDataPoint |
extractDataPoint()
Extract a
GaugeDataPoint from this object. |
GaugeDescriptor |
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.
|
Long |
getValue() |
boolean |
isValid()
Indicates whether this
TimeStampedMetric 's current value is a
valid one. |
void |
reset()
Prepares the gauge for use in a new time period by saving the most recent
update time stamp as the previous time stamp.
|
void |
setDescriptor(GaugeDescriptor toSet)
Sets the
GaugeDescriptor that specifies characteristics of this
TimeStampedGauge . |
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.
|
void |
setValue(long toSet)
Sets the value of this
TimeStampedGauge . |
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 static final long UNINITIALIZED
public TimeStampedGauge(MetricRegistry registry, GaugeDescriptor descriptor)
TimeStampedGauge
with the specified characteristics
using the specified MetricRegistry
.registry
- MetricRegistry
to use for allocating this objectdescriptor
- GaugeDescriptor
that specifies various
characteristics of the resulting TimeStampedGauge
public TimeStampedGauge(MetricRegistry registry, GaugeDescriptor descriptor, String uid)
TimeStampedGauge
with the specified UID and other
characteristics using the specified MetricRegistry
.registry
- MetricRegistry
to use for allocating this objectdescriptor
- GaugeDescriptor
that specifies various
characteristics of the resulting TimeStampedGauge
uid
- UID to assign to the resulting TimeStampedGauge
IllegalArgumentException
- if a null value is supplied for either
the GaugeDescriptor
or MetricRegistry
argumentpublic GaugeDataPoint extractDataPoint()
GaugeDataPoint
from this object.extractDataPoint
in interface TimeStampedMetric
GaugeDataPoint
public GaugeDescriptor getDescriptor()
TimeStampedMetric
MetricDescriptor
that describes this TimeStampedMetric
object.getDescriptor
in interface TimeStampedMetric
MetricDescriptor
that describes this TimeStampedMetric
public long getMsSpanned()
TimeStampedMetric
getMsSpanned
in interface TimeStampedMetric
public long getPreviousTimeStamp()
TimeStampedMetric
getPreviousTimeStamp
in interface TimeStampedMetric
protected TimeStampManager getTimeStampManager()
TimeStampManager
that this object uses to manage its
associated time stamps.TimeStampManager
for this objectpublic String getUid()
TimeStampedMetric
getUid
in interface TimeStampedMetric
public long getUpdateTimeStamp()
TimeStampedMetric
getUpdateTimeStamp
in interface TimeStampedMetric
public Long getValue()
getValue
in interface com.codahale.metrics.Gauge<Long>
public boolean isValid()
TimeStampedMetric
TimeStampedMetric
's current value is a
valid one. For example, it could be a non-numeric value like Double.NaN,
depending upon type and state of the TimeStampedMetric
.isValid
in interface TimeStampedMetric
true
if valid, false
otherwisepublic void reset()
reset
in interface TimeStampedMetric
public void setDescriptor(GaugeDescriptor toSet)
GaugeDescriptor
that specifies characteristics of this
TimeStampedGauge
.toSet
- the GaugeDescriptor
for this objectpublic void setPreviousTimeStamp(long time)
TimeStampedMetric
setPreviousTimeStamp
in interface TimeStampedMetric
time
- previous time stamppublic void setUid(String toSet)
TimeStampedMetric
setUid
in interface TimeStampedMetric
toSet
- new UID for this objectpublic void setUpdateTimeStamp(long time)
TimeStampedMetric
setUpdateTimeStamp
in interface TimeStampedMetric
time
- update time stamppublic void setValue(long toSet)
TimeStampedGauge
.toSet
- the value for this objectpublic String toDebugString()
public void updateTimeStamp()
TimeStampedMetric
updateTimeStamp
in interface TimeStampedMetric
Copyright © 2016. All Rights Reserved.