Class LongLastValueAggregator
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.aggregator.LongLastValueAggregator
-
- All Implemented Interfaces:
Aggregator<LongPointData,LongExemplarData>
public final class LongLastValueAggregator extends java.lang.Object implements Aggregator<LongPointData,LongExemplarData>
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 classLongLastValueAggregator.Handle
-
Field Summary
Fields Modifier and Type Field Description private MemoryModememoryModeprivate java.util.function.Supplier<ExemplarReservoir<LongExemplarData>>reservoirSupplier
-
Constructor Summary
Constructors Constructor Description LongLastValueAggregator(java.util.function.Supplier<ExemplarReservoir<LongExemplarData>> reservoirSupplier, MemoryMode memoryMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyPoint(LongPointData point, LongPointData toReusablePoint)CopiespointintotoReusablePoint.AggregatorHandle<LongPointData,LongExemplarData>createHandle()Returns a newAggregatorHandle.LongPointDatacreateReusablePoint()Creates a new reusable point.LongPointDatadiff(LongPointData previous, LongPointData current)Returns a new DELTA point by computing the difference between two cumulative points.voiddiffInPlace(LongPointData previousReusablePoint, LongPointData currentPoint)Resets one reusable point to be a DELTA point by computing the difference between two cumulative points.MetricDatatoMetricData(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, MetricDescriptor descriptor, java.util.Collection<LongPointData> points, AggregationTemporality temporality)Returns theMetricDatathat thisAggregationwill produce.LongPointDatatoPoint(Measurement measurement)Return a new point representing the measurement.voidtoPoint(Measurement measurement, LongPointData reusablePoint)ResetsreusablePointto represent themeasurement.
-
-
-
Field Detail
-
reservoirSupplier
private final java.util.function.Supplier<ExemplarReservoir<LongExemplarData>> reservoirSupplier
-
memoryMode
private final MemoryMode memoryMode
-
-
Constructor Detail
-
LongLastValueAggregator
public LongLastValueAggregator(java.util.function.Supplier<ExemplarReservoir<LongExemplarData>> reservoirSupplier, MemoryMode memoryMode)
-
-
Method Detail
-
createHandle
public AggregatorHandle<LongPointData,LongExemplarData> createHandle()
Description copied from interface:AggregatorReturns a newAggregatorHandle. This MUST by used by the synchronous to aggregate recorded measurements during the collection cycle.- Specified by:
createHandlein interfaceAggregator<LongPointData,LongExemplarData>- Returns:
- a new
AggregatorHandle.
-
diff
public LongPointData diff(LongPointData previous, LongPointData current)
Description copied from interface:AggregatorReturns 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:
diffin interfaceAggregator<LongPointData,LongExemplarData>- Parameters:
previous- the previously captured point.current- the newly captured (cumulative) point.- Returns:
- The resulting delta point.
-
diffInPlace
public void diffInPlace(LongPointData previousReusablePoint, LongPointData currentPoint)
Description copied from interface:AggregatorResets 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
previousCumulativeReusableAggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
diffInPlacein interfaceAggregator<LongPointData,LongExemplarData>- Parameters:
previousReusablePoint- the previously captured point.currentPoint- the newly captured (cumulative) point.
-
toPoint
public LongPointData toPoint(Measurement measurement)
Description copied from interface:AggregatorReturn a new point representing the measurement.Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
toPointin interfaceAggregator<LongPointData,LongExemplarData>
-
toPoint
public void toPoint(Measurement measurement, LongPointData reusablePoint)
Description copied from interface:AggregatorResetsreusablePointto represent themeasurement.Aggregators MUST implement diff if it can be used with asynchronous instruments.
- Specified by:
toPointin interfaceAggregator<LongPointData,LongExemplarData>
-
createReusablePoint
public LongPointData createReusablePoint()
Description copied from interface:AggregatorCreates a new reusable point.- Specified by:
createReusablePointin interfaceAggregator<LongPointData,LongExemplarData>
-
copyPoint
public void copyPoint(LongPointData point, LongPointData toReusablePoint)
Description copied from interface:AggregatorCopiespointintotoReusablePoint.- Specified by:
copyPointin interfaceAggregator<LongPointData,LongExemplarData>
-
toMetricData
public MetricData toMetricData(Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, MetricDescriptor descriptor, java.util.Collection<LongPointData> points, AggregationTemporality temporality)
Description copied from interface:AggregatorReturns theMetricDatathat thisAggregationwill produce.- Specified by:
toMetricDatain interfaceAggregator<LongPointData,LongExemplarData>- 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
MetricDataTypethat thisAggregationwill produce.
-
-