Class DoubleLastValueAggregator
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.aggregator.DoubleLastValueAggregator
-
- All Implemented Interfaces:
Aggregator<DoublePointData,DoubleExemplarData>
@ThreadSafe public final class DoubleLastValueAggregator extends java.lang.Object implements Aggregator<DoublePointData,DoubleExemplarData>
Aggregator that aggregates recorded values by storing the last recorded value.Limitation: The current implementation does not store a time when the value was recorded, so merging multiple LastValueAggregators will not preserve the ordering of records. This is not a problem because LastValueAggregator is currently only available for Observers which record all values once.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DoubleLastValueAggregator.Handle
-
Field Summary
Fields Modifier and Type Field Description private MemoryMode
memoryMode
private java.util.function.Supplier<ExemplarReservoir<DoubleExemplarData>>
reservoirSupplier
-
Constructor Summary
Constructors Constructor Description DoubleLastValueAggregator(java.util.function.Supplier<ExemplarReservoir<DoubleExemplarData>> reservoirSupplier, MemoryMode memoryMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyPoint(DoublePointData point, DoublePointData toReusablePoint)
Copiespoint
intotoReusablePoint
.AggregatorHandle<DoublePointData,DoubleExemplarData>
createHandle()
Returns a newAggregatorHandle
.DoublePointData
createReusablePoint()
Creates a new reusable point.DoublePointData
diff(DoublePointData previous, DoublePointData current)
Returns a new DELTA point by computing the difference between two cumulative points.void
diffInPlace(DoublePointData previousReusable, DoublePointData current)
Resets one reusable point to be a DELTA point by computing the difference between two cumulative points.MetricData
toMetricData(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, MetricDescriptor descriptor, java.util.Collection<DoublePointData> points, AggregationTemporality temporality)
Returns theMetricData
that thisAggregation
will produce.DoublePointData
toPoint(Measurement measurement)
Return a new point representing the measurement.void
toPoint(Measurement measurement, DoublePointData reusablePoint)
ResetsreusablePoint
to represent themeasurement
.
-
-
-
Field Detail
-
reservoirSupplier
private final java.util.function.Supplier<ExemplarReservoir<DoubleExemplarData>> reservoirSupplier
-
memoryMode
private final MemoryMode memoryMode
-
-
Constructor Detail
-
DoubleLastValueAggregator
public DoubleLastValueAggregator(java.util.function.Supplier<ExemplarReservoir<DoubleExemplarData>> reservoirSupplier, MemoryMode memoryMode)
-
-
Method Detail
-
createHandle
public AggregatorHandle<DoublePointData,DoubleExemplarData> createHandle()
Description copied from interface:Aggregator
Returns a newAggregatorHandle
. This MUST by used by the synchronous to aggregate recorded measurements during the collection cycle.- Specified by:
createHandle
in interfaceAggregator<DoublePointData,DoubleExemplarData>
- Returns:
- a new
AggregatorHandle
.
-
diff
public DoublePointData diff(DoublePointData previous, DoublePointData current)
Description copied from interface:Aggregator
Returns a new DELTA point by computing the difference between two cumulative points.Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
diff
in interfaceAggregator<DoublePointData,DoubleExemplarData>
- Parameters:
previous
- the previously captured point.current
- the newly captured (cumulative) point.- Returns:
- The resulting delta point.
-
diffInPlace
public void diffInPlace(DoublePointData previousReusable, DoublePointData current)
Description copied from interface:Aggregator
Resets one reusable point to be a DELTA point by computing the difference between two cumulative points.The delta between the two points is set on
previousCumulativeReusable
Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
diffInPlace
in interfaceAggregator<DoublePointData,DoubleExemplarData>
- Parameters:
previousReusable
- the previously captured point.current
- the newly captured (cumulative) point.
-
toPoint
public DoublePointData toPoint(Measurement measurement)
Description copied from interface:Aggregator
Return a new point representing the measurement.Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
toPoint
in interfaceAggregator<DoublePointData,DoubleExemplarData>
-
toPoint
public void toPoint(Measurement measurement, DoublePointData reusablePoint)
Description copied from interface:Aggregator
ResetsreusablePoint
to represent themeasurement
.Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
toPoint
in interfaceAggregator<DoublePointData,DoubleExemplarData>
-
createReusablePoint
public DoublePointData createReusablePoint()
Description copied from interface:Aggregator
Creates a new reusable point.- Specified by:
createReusablePoint
in interfaceAggregator<DoublePointData,DoubleExemplarData>
-
copyPoint
public void copyPoint(DoublePointData point, DoublePointData toReusablePoint)
Description copied from interface:Aggregator
Copiespoint
intotoReusablePoint
.- Specified by:
copyPoint
in interfaceAggregator<DoublePointData,DoubleExemplarData>
-
toMetricData
public MetricData toMetricData(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, MetricDescriptor descriptor, java.util.Collection<DoublePointData> points, AggregationTemporality temporality)
Description copied from interface:Aggregator
Returns theMetricData
that thisAggregation
will produce.- Specified by:
toMetricData
in interfaceAggregator<DoublePointData,DoubleExemplarData>
- Parameters:
resource
- the resource producing the metric.instrumentationScopeInfo
- the scope that instrumented the metric.descriptor
- the name, description and unit of the metric.points
- list of pointstemporality
- the temporality of the metric.- Returns:
- the
MetricDataType
that thisAggregation
will produce.
-
-