Class AggregatorHandle<T extends PointData,U extends ExemplarData>
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.aggregator.AggregatorHandle<T,U>
-
- Direct Known Subclasses:
DoubleBase2ExponentialHistogramAggregator.Handle
,DoubleExplicitBucketHistogramAggregator.Handle
,DoubleLastValueAggregator.Handle
,DoubleSumAggregator.Handle
,LongLastValueAggregator.Handle
,LongSumAggregator.Handle
@ThreadSafe public abstract class AggregatorHandle<T extends PointData,U extends ExemplarData> extends java.lang.Object
Aggregator represents the abstract class that is used for synchronous instruments. It must be thread-safe and avoid locking when possible, because values are recorded synchronously on the calling thread.An
AggregatorHandle
must be created for every uniqueAttributes
recorded.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private ExemplarReservoir<U>
exemplarReservoir
private boolean
valuesRecorded
-
Constructor Summary
Constructors Modifier Constructor Description protected
AggregatorHandle(ExemplarReservoir<U> exemplarReservoir)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
aggregateThenMaybeReset(long startEpochNanos, long epochNanos, Attributes attributes, boolean reset)
Returns the current value into asAggregatorHandle
.protected abstract T
doAggregateThenMaybeReset(long startEpochNanos, long epochNanos, Attributes attributes, java.util.List<U> exemplars, boolean reset)
Implementation of theaggregateThenMaybeReset(long, long, Attributes, boolean)
.protected void
doRecordDouble(double value)
Concrete Aggregator instances should implement this method in order support recordings of double values.protected void
doRecordLong(long value)
Concrete Aggregator instances should implement this method in order support recordings of long values.boolean
hasRecordedValues()
Checks whether this handle has values recorded.void
recordDouble(double value)
Updates the current aggregator with a newly recordeddouble
value.void
recordDouble(double value, Attributes attributes, Context context)
void
recordLong(long value)
Updates the current aggregator with a newly recordedlong
value.void
recordLong(long value, Attributes attributes, Context context)
-
-
-
Field Detail
-
exemplarReservoir
private final ExemplarReservoir<U extends ExemplarData> exemplarReservoir
-
valuesRecorded
private volatile boolean valuesRecorded
-
-
Constructor Detail
-
AggregatorHandle
protected AggregatorHandle(ExemplarReservoir<U> exemplarReservoir)
-
-
Method Detail
-
aggregateThenMaybeReset
public final T aggregateThenMaybeReset(long startEpochNanos, long epochNanos, Attributes attributes, boolean reset)
Returns the current value into asAggregatorHandle
. Ifreset
istrue
, resets the current value in thisAggregator
.
-
doAggregateThenMaybeReset
protected abstract T doAggregateThenMaybeReset(long startEpochNanos, long epochNanos, Attributes attributes, java.util.List<U> exemplars, boolean reset)
Implementation of theaggregateThenMaybeReset(long, long, Attributes, boolean)
.
-
recordLong
public final void recordLong(long value, Attributes attributes, Context context)
-
recordLong
public final void recordLong(long value)
Updates the current aggregator with a newly recordedlong
value.Visible for Testing
- Parameters:
value
- the newlong
value to be added.
-
doRecordLong
protected void doRecordLong(long value)
Concrete Aggregator instances should implement this method in order support recordings of long values.
-
recordDouble
public final void recordDouble(double value, Attributes attributes, Context context)
-
recordDouble
public final void recordDouble(double value)
Updates the current aggregator with a newly recordeddouble
value.Visible for Testing
- Parameters:
value
- the newdouble
value to be added.
-
doRecordDouble
protected void doRecordDouble(double value)
Concrete Aggregator instances should implement this method in order support recordings of double values.
-
hasRecordedValues
public boolean hasRecordedValues()
Checks whether this handle has values recorded.- Returns:
- True if values has been recorded to it
-
-