|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.netflix.servo.publish.CounterToRateMetricTransform
public final class CounterToRateMetricTransform
Converts counter metrics into a rate per second. The rate is calculated by comparing two samples of given metric and looking at the delta. Since two samples are needed to calculate the rate, no value will be sent to the wrapped observer until a second sample arrives. If a given metric is not updated within a given heartbeat interval, the previous cached value for the counter will be dropped such that if a new sample comes in it will be treated as the first sample for that metric.
Counters should be monotonically increasing values. If a counter value decreases from one sample to the next, then we will assume the counter value was reset and send a rate of 0. This is similar to the RRD concept of type DERIVE with a min of 0.
This class is not thread safe and should generally be wrapped by an async observer to prevent issues.
| Constructor Summary | |
|---|---|
CounterToRateMetricTransform(MetricObserver observer,
long heartbeat,
long estPollingInterval,
java.util.concurrent.TimeUnit unit)
Creates a new instance with the specified heartbeat interval. |
|
CounterToRateMetricTransform(MetricObserver observer,
long heartbeat,
java.util.concurrent.TimeUnit unit)
Creates a new instance with the specified heartbeat interval. |
|
| Method Summary | |
|---|---|
java.lang.String |
getName()
Name associated with an observer. |
void |
reset()
Clear all cached state of previous counter values. |
void |
update(java.util.List<Metric> metrics)
Invoked with the most recent values for a set of metrics. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CounterToRateMetricTransform(MetricObserver observer,
long heartbeat,
java.util.concurrent.TimeUnit unit)
public CounterToRateMetricTransform(MetricObserver observer,
long heartbeat,
long estPollingInterval,
java.util.concurrent.TimeUnit unit)
observer - downstream observer to forward values to after the rate has
been computed.heartbeat - how long to remember a previous value before dropping it and
treating new samples as the first report.estPollingInterval - estimated polling interval in to use for the first call. If set
to zero no values will be forwarded until the second sample for
a given counter. The delta for the first interval will be the
total value for the counter as it is assumed it started at 0 and
was first created since the last polling interval. If this
assumption is not true then this setting should be 0 so it waits
for the next sample to compute an accurate delta, otherwise
spikes will occur in the output.unit - unit for the heartbeat and estPollingInterval params.| Method Detail |
|---|
public java.lang.String getName()
getName in interface MetricObserverpublic void update(java.util.List<Metric> metrics)
update in interface MetricObserverpublic void reset()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||