Class FixedSizeExemplarReservoir<T extends ExemplarData>
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.exemplar.FixedSizeExemplarReservoir<T>
-
- All Implemented Interfaces:
ExemplarReservoir<T>
- Direct Known Subclasses:
HistogramExemplarReservoir,RandomFixedSizeExemplarReservoir
abstract class FixedSizeExemplarReservoir<T extends ExemplarData> extends java.lang.Object implements ExemplarReservoir<T>
Base for fixed-size reservoir sampling of Exemplars.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanhasMeasurementsprivate java.util.function.BiFunction<ReservoirCell,Attributes,T>mapAndResetCellprivate ReservoirCellSelectorreservoirCellSelectorprivate ReservoirCell[]storage
-
Constructor Summary
Constructors Constructor Description FixedSizeExemplarReservoir(Clock clock, int size, ReservoirCellSelector reservoirCellSelector, java.util.function.BiFunction<ReservoirCell,Attributes,T> mapAndResetCell)Instantiates an exemplar reservoir of fixed size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<T>collectAndReset(Attributes pointAttributes)Returns an immutable list of Exemplars for exporting from the current reservoir.voidofferDoubleMeasurement(double value, Attributes attributes, Context context)Offers adoublemeasurement to be sampled.voidofferLongMeasurement(long value, Attributes attributes, Context context)Offers alongmeasurement to be sampled.
-
-
-
Field Detail
-
storage
private final ReservoirCell[] storage
-
reservoirCellSelector
private final ReservoirCellSelector reservoirCellSelector
-
mapAndResetCell
private final java.util.function.BiFunction<ReservoirCell,Attributes,T extends ExemplarData> mapAndResetCell
-
hasMeasurements
private volatile boolean hasMeasurements
-
-
Constructor Detail
-
FixedSizeExemplarReservoir
FixedSizeExemplarReservoir(Clock clock, int size, ReservoirCellSelector reservoirCellSelector, java.util.function.BiFunction<ReservoirCell,Attributes,T> mapAndResetCell)
Instantiates an exemplar reservoir of fixed size.
-
-
Method Detail
-
offerLongMeasurement
public void offerLongMeasurement(long value, Attributes attributes, Context context)Description copied from interface:ExemplarReservoirOffers alongmeasurement to be sampled.- Specified by:
offerLongMeasurementin interfaceExemplarReservoir<T extends ExemplarData>
-
offerDoubleMeasurement
public void offerDoubleMeasurement(double value, Attributes attributes, Context context)Description copied from interface:ExemplarReservoirOffers adoublemeasurement to be sampled.- Specified by:
offerDoubleMeasurementin interfaceExemplarReservoir<T extends ExemplarData>
-
collectAndReset
public java.util.List<T> collectAndReset(Attributes pointAttributes)
Description copied from interface:ExemplarReservoirReturns an immutable list of Exemplars for exporting from the current reservoir.Additionally, clears the reservoir for the next sampling period.
- Specified by:
collectAndResetin interfaceExemplarReservoir<T extends ExemplarData>- Parameters:
pointAttributes- theAttributesassociated with the metric point.ExemplarDatas should filter these out of their final data state.- Returns:
- An (immutable) list of sampled exemplars for this point. Implementers are expected to
filter out
pointAttributesfrom the original recorded attributes.
-
-