Interface ExemplarReservoir<T extends ExemplarData>
- All Known Implementing Classes:
FilteredExemplarReservoir,FixedSizeExemplarReservoir,HistogramExemplarReservoir,LongToDoubleExemplarReservoir,NoopExemplarReservoir,RandomFixedSizeExemplarReservoir
public interface ExemplarReservoir<T extends ExemplarData>
An interface for an exemplar reservoir of samples.
This represents a reservoir for a specific "point" of metric data.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Method Summary
Modifier and TypeMethodDescriptioncollectAndReset(Attributes pointAttributes) Returns an immutable list of Exemplars for exporting from the current reservoir.static ExemplarReservoir<DoubleExemplarData> doubleFixedSizeReservoir(Clock clock, int size, Supplier<Random> randomSupplier) A double reservoir with fixed size that stores the given number of exemplars.static ExemplarReservoir<DoubleExemplarData> A double exemplar reservoir that stores no exemplars.static <T extends ExemplarData>
ExemplarReservoir<T> filtered(ExemplarFilter filter, ExemplarReservoir<T> original) Wraps aExemplarReservoirwith a measurement pre-filter.static ExemplarReservoir<DoubleExemplarData> histogramBucketReservoir(Clock clock, List<Double> boundaries) A Reservoir sampler that preserves the latest seen measurement per-histogram bucket.static ExemplarReservoir<LongExemplarData> longFixedSizeReservoir(Clock clock, int size, Supplier<Random> randomSupplier) A long reservoir with fixed size that stores the given number of exemplars.static ExemplarReservoir<LongExemplarData> A long exemplar reservoir that stores no exemplars.static <T extends ExemplarData>
ExemplarReservoir<T> longToDouble(ExemplarReservoir<T> delegate) Wraps anExemplarReservoir, casting calls fromofferLongMeasurement(long, Attributes, Context)toofferDoubleMeasurement(double, Attributes, Context)such thatcollectAndReset(Attributes)only returnsDoubleExemplarData.voidofferDoubleMeasurement(double value, Attributes attributes, Context context) Offers adoublemeasurement to be sampled.voidofferLongMeasurement(long value, Attributes attributes, Context context) Offers alongmeasurement to be sampled.
-
Method Details
-
longToDouble
Wraps anExemplarReservoir, casting calls fromofferLongMeasurement(long, Attributes, Context)toofferDoubleMeasurement(double, Attributes, Context)such thatcollectAndReset(Attributes)only returnsDoubleExemplarData.This is used for
Aggregation.explicitBucketHistogram()andAggregation.base2ExponentialBucketHistogram()which only support double measurements. -
filtered
static <T extends ExemplarData> ExemplarReservoir<T> filtered(ExemplarFilter filter, ExemplarReservoir<T> original) Wraps aExemplarReservoirwith a measurement pre-filter. -
doubleNoSamples
A double exemplar reservoir that stores no exemplars. -
longNoSamples
A long exemplar reservoir that stores no exemplars. -
doubleFixedSizeReservoir
static ExemplarReservoir<DoubleExemplarData> doubleFixedSizeReservoir(Clock clock, int size, Supplier<Random> randomSupplier) A double reservoir with fixed size that stores the given number of exemplars.- Parameters:
clock- The clock to use when annotating measurements with time.size- The maximum number of exemplars to preserve.randomSupplier- The random number generator to use for sampling.
-
longFixedSizeReservoir
static ExemplarReservoir<LongExemplarData> longFixedSizeReservoir(Clock clock, int size, Supplier<Random> randomSupplier) A long reservoir with fixed size that stores the given number of exemplars.- Parameters:
clock- The clock to use when annotating measurements with time.size- The maximum number of exemplars to preserve.randomSupplier- The random number generator to use for sampling.
-
histogramBucketReservoir
static ExemplarReservoir<DoubleExemplarData> histogramBucketReservoir(Clock clock, List<Double> boundaries) A Reservoir sampler that preserves the latest seen measurement per-histogram bucket.- Parameters:
clock- The clock to use when annotating measurements with time.boundaries- A list of (inclusive) upper bounds for the histogram. Should be in order from lowest to highest.
-
offerDoubleMeasurement
Offers adoublemeasurement to be sampled. -
offerLongMeasurement
Offers alongmeasurement to be sampled. -
collectAndReset
Returns an immutable list of Exemplars for exporting from the current reservoir.Additionally, clears the reservoir for the next sampling period.
- 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.
-