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
All Methods Static Methods Instance Methods Abstract 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.static ExemplarReservoir<DoubleExemplarData>doubleFixedSizeReservoir(Clock clock, int size, java.util.function.Supplier<java.util.Random> randomSupplier)A double reservoir with fixed size that stores the given number of exemplars.static ExemplarReservoir<DoubleExemplarData>doubleNoSamples()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, java.util.List<java.lang.Double> boundaries)A Reservoir sampler that preserves the latest seen measurement per-histogram bucket.static ExemplarReservoir<LongExemplarData>longFixedSizeReservoir(Clock clock, int size, java.util.function.Supplier<java.util.Random> randomSupplier)A long reservoir with fixed size that stores the given number of exemplars.static ExemplarReservoir<LongExemplarData>longNoSamples()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 Detail
-
longToDouble
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.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
static ExemplarReservoir<DoubleExemplarData> doubleNoSamples()
A double exemplar reservoir that stores no exemplars.
-
longNoSamples
static ExemplarReservoir<LongExemplarData> longNoSamples()
A long exemplar reservoir that stores no exemplars.
-
doubleFixedSizeReservoir
static ExemplarReservoir<DoubleExemplarData> doubleFixedSizeReservoir(Clock clock, int size, java.util.function.Supplier<java.util.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, java.util.function.Supplier<java.util.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, java.util.List<java.lang.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
void offerDoubleMeasurement(double value, Attributes attributes, Context context)Offers adoublemeasurement to be sampled.
-
offerLongMeasurement
void offerLongMeasurement(long value, Attributes attributes, Context context)Offers alongmeasurement to be sampled.
-
collectAndReset
java.util.List<T> collectAndReset(Attributes pointAttributes)
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.
-
-