java.io.Closeable, java.lang.AutoCloseable@Public @Evolving public class MutableRollingAverages extends MutableMetric implements java.io.Closeable
This class maintains a group of rolling average metrics. It implements the algorithm of rolling average, i.e. a number of sliding windows are kept to roll over and evict old subsets of samples. Each window has a subset of samples in a stream, where sub-sum and sub-total are collected. All sub-sums and sub-totals in all windows will be aggregated to final-sum and final-total used to compute final average, which is called rolling average.
| Constructor | Description |
|---|---|
MutableRollingAverages(java.lang.String metricValueName) |
Constructor for
MutableRollingAverages. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
add(java.lang.String name,
long value) |
|
void |
close() |
|
void |
collectThreadLocalStates() |
Collects states maintained in
ThreadLocal, if any. |
java.util.Map<java.lang.String,java.lang.Double> |
getStats(long minSamples) |
Retrieve a map of metric name -> (aggregate).
|
void |
setRecordValidityMs(long value) |
Use for test only.
|
void |
snapshot(MetricsRecordBuilder builder,
boolean all) |
Get a snapshot of the metric
|
changed, clearChanged, setChanged, snapshotpublic MutableRollingAverages(java.lang.String metricValueName)
MutableRollingAverages.metricValueName - input metricValueName.public void snapshot(MetricsRecordBuilder builder, boolean all)
MutableMetricsnapshot in class MutableMetricbuilder - the metrics record builderall - if true, snapshot unchanged metrics as wellpublic void collectThreadLocalStates()
ThreadLocal, if any.public void add(java.lang.String name,
long value)
name - name of metricvalue - value of metricpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic java.util.Map<java.lang.String,java.lang.Double> getStats(long minSamples)
minSamples - input minSamples.@VisibleForTesting public void setRecordValidityMs(long value)
value - input value.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.