Interface Aggregator<T>
-
- All Known Implementing Classes:
AbstractAggregator
@Immutable public interface Aggregator<T>Aggregator represents the abstract class for all the available aggregations that can be computed during the accumulation phase for all the instrument.The synchronous instruments will create an
AggregatorHandleto record individual measurements synchronously, and for asynchronous theaccumulateDouble(double)oraccumulateLong(long)will be used when reading values from the instrument callbacks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default TaccumulateDouble(double value)Returns a newAccumulationfor the given value.default TaccumulateLong(long value)Returns a newAccumulationfor the given value.AggregatorHandle<T>createHandle()Returns a newAggregatorHandle.booleanisStateful()Returnstrueif the processor needs to keep the previous collected state in order to compute the desired metric.Tmerge(T a1, T a2)Returns the result of the merge of the given accumulations.MetricDatatoMetricData(Map<io.opentelemetry.api.metrics.common.Labels,T> accumulationByLabels, long startEpochNanos, long lastCollectionEpoch, long epochNanos)Returns theMetricDatathat thisAggregationwill produce.
-
-
-
Method Detail
-
createHandle
AggregatorHandle<T> createHandle()
Returns a newAggregatorHandle. This MUST by used by the synchronous to aggregate recorded measurements during the collection cycle.- Returns:
- a new
AggregatorHandle.
-
accumulateLong
default T accumulateLong(long value)
Returns a newAccumulationfor the given value. This MUST be used by the asynchronous instruments to createAccumulationthat are passed to the processor.- Parameters:
value- the given value to be used to create theAccumulation.- Returns:
- a new
Accumulationfor the given value.
-
accumulateDouble
default T accumulateDouble(double value)
Returns a newAccumulationfor the given value. This MUST be used by the asynchronous instruments to createAccumulationthat are passed to the processor.- Parameters:
value- the given value to be used to create theAccumulation.- Returns:
- a new
Accumulationfor the given value.
-
merge
T merge(T a1, T a2)
Returns the result of the merge of the given accumulations.- Returns:
- the result of the merge of the given accumulations.
-
isStateful
boolean isStateful()
Returnstrueif the processor needs to keep the previous collected state in order to compute the desired metric.- Returns:
trueif the processor needs to keep the previous collected state.
-
toMetricData
@Nullable MetricData toMetricData(Map<io.opentelemetry.api.metrics.common.Labels,T> accumulationByLabels, long startEpochNanos, long lastCollectionEpoch, long epochNanos)
Returns theMetricDatathat thisAggregationwill produce.- Parameters:
accumulationByLabels- the map of Labels to Accumulation.startEpochNanos- the startEpochNanos for thePoint.epochNanos- the epochNanos for thePoint.- Returns:
- the
MetricDataTypethat thisAggregationwill produce.
-
-