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 interface
DefaultExemplarSampler.Clock
(package private) static class
DefaultExemplarSampler.SystemClock
-
Field Summary
Fields Modifier and Type Field Description private DefaultExemplarSampler.Clock
clock
private long
minRetentionIntervalMs
private static java.lang.String
SPAN_ID
private SpanContextSupplier
spanContextSupplier
private static java.lang.String
TRACE_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:
sample
in interfaceCounterExemplarSampler
- Parameters:
increment
- the value added to the counter on this eventprevious
- the previously sampled exemplar, ornull
if there is none.- Returns:
- an Exemplar to be sampled, or
null
if the previous exemplar does not need to be updated. Returningnull
and returningprevious
is equivalent.
-
sample
public Exemplar sample(double value, double bucketFrom, double bucketTo, Exemplar previous)
- Specified by:
sample
in interfaceHistogramExemplarSampler
- Parameters:
value
- the value to be observed.bucketFrom
- upper boundary of the previous bucket in the histogram. Will beDouble.NEGATIVE_INFINITY
if there is no previous bucket.bucketTo
- upper boundary of this histogram bucket. Will beDouble.POSITIVE_INFINITY
if this is the last bucket.previous
- the previously sampled exemplar, ornull
if there is none.- Returns:
- an Exemplar to be sampled, or
null
if the previous exemplar does not need to be updated. Returningnull
and returningprevious
is equivalent.
-
-