public final class CounterToRateMetricTransform extends java.lang.Object implements MetricObserver
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 and Description |
---|
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.
|
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.public java.lang.String getName()
getName
in interface MetricObserver
public void update(java.util.List<Metric> metrics)
update
in interface MetricObserver
public void reset()