Package io.prometheus.client.exemplars
Class DefaultExemplarSampler
- java.lang.Object
-
- io.prometheus.client.exemplars.DefaultExemplarSampler
-
- All Implemented Interfaces:
CounterExemplarSampler,ExemplarSampler,HistogramExemplarSampler
public class DefaultExemplarSampler extends java.lang.Object implements ExemplarSampler
Default Exemplar sampler.Keeps each Exemplar for a minimum of ~7 seconds, then samples a new one.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceDefaultExemplarSampler.Clock(package private) static classDefaultExemplarSampler.SystemClock
-
Field Summary
Fields Modifier and Type Field Description private DefaultExemplarSampler.Clockclockprivate longminRetentionIntervalMsprivate static java.lang.StringSPAN_IDprivate SpanContextSupplierspanContextSupplierprivate static java.lang.StringTRACE_ID
-
Constructor Summary
Constructors Constructor Description DefaultExemplarSampler(SpanContextSupplier spanContextSupplier)DefaultExemplarSampler(SpanContextSupplier spanContextSupplier, DefaultExemplarSampler.Clock clock)
-
-
-
Field Detail
-
SPAN_ID
private static final java.lang.String SPAN_ID
- See Also:
- Constant Field Values
-
TRACE_ID
private static final java.lang.String TRACE_ID
- See Also:
- Constant Field Values
-
spanContextSupplier
private final SpanContextSupplier spanContextSupplier
-
minRetentionIntervalMs
private final long minRetentionIntervalMs
- See Also:
- Constant Field Values
-
clock
private final DefaultExemplarSampler.Clock clock
-
-
Constructor Detail
-
DefaultExemplarSampler
public DefaultExemplarSampler(SpanContextSupplier spanContextSupplier)
-
DefaultExemplarSampler
DefaultExemplarSampler(SpanContextSupplier spanContextSupplier, DefaultExemplarSampler.Clock clock)
-
-
Method Detail
-
sample
public Exemplar sample(double increment, Exemplar previous)
- Specified by:
samplein interfaceCounterExemplarSampler- Parameters:
increment- the value added to the counter on this eventprevious- the previously sampled exemplar, ornullif there is none.- Returns:
- an Exemplar to be sampled, or
nullif the previous exemplar does not need to be updated. Returningnulland returningpreviousis equivalent.
-
sample
public Exemplar sample(double value, double bucketFrom, double bucketTo, Exemplar previous)
- Specified by:
samplein interfaceHistogramExemplarSampler- Parameters:
value- the value to be observed.bucketFrom- upper boundary of the previous bucket in the histogram. Will beDouble.NEGATIVE_INFINITYif there is no previous bucket.bucketTo- upper boundary of this histogram bucket. Will beDouble.POSITIVE_INFINITYif this is the last bucket.previous- the previously sampled exemplar, ornullif there is none.- Returns:
- an Exemplar to be sampled, or
nullif the previous exemplar does not need to be updated. Returningnulland returningpreviousis equivalent.
-
-