Class Histogram.Child
- Enclosing class:
Histogram
Warning: References to a Child become invalid after using
SimpleCollector.remove(java.lang.String...)
or SimpleCollector.clear()
.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final DoubleAdder[]
private final ArrayList
<AtomicReference<Exemplar>> private final HistogramExemplarSampler
private final Boolean
private final DoubleAdder
private final double[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Child
(double[] buckets, Boolean exemplarsEnabled, HistogramExemplarSampler exemplarSampler) -
Method Summary
Modifier and TypeMethodDescriptionget()
Get the value of the Histogram.void
observe
(double amt) Observe the given amount.void
observeWithExemplar
(double amt, String... exemplarLabels) Likeobserve(double)
, but additionally creates an exemplar.void
observeWithExemplar
(double amt, Map<String, String> exemplarLabels) LikeobserveWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
.private Exemplar
sampleNextExemplar
(double amt, double bucketFrom, double bucketTo, Exemplar prev) Start a timer to track a duration.double
Executes runnable code (e.g.<E> E
Executes callable code (e.g.double
timeWithExemplar
(Runnable timeable, String... exemplarLabels) Liketime(Runnable)
, but additionally create an exemplar.double
timeWithExemplar
(Runnable timeable, Map<String, String> exemplarLabels) Liketime(Runnable)
, but additionally create an exemplar.<E> E
timeWithExemplar
(Callable<E> timeable, String... exemplarLabels) Liketime(Callable)
, but additionally create an exemplar.<E> E
timeWithExemplar
(Callable<E> timeable, Map<String, String> exemplarLabels) Liketime(Callable)
, but additionally create an exemplar.private void
updateExemplar
(double amt, int i, Exemplar userProvidedExemplar)
-
Field Details
-
exemplars
-
exemplarsEnabled
-
exemplarSampler
-
upperBounds
private final double[] upperBounds -
cumulativeCounts
-
sum
-
created
private final long created
-
-
Constructor Details
-
Child
-
-
Method Details
-
time
Executes runnable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run.- Parameters:
timeable
- Code that is being timed- Returns:
- Measured duration in seconds for timeable to complete.
-
timeWithExemplar
Liketime(Runnable)
, but additionally create an exemplar.See
observeWithExemplar(double, String...)
for documentation on theexemplarLabels
parameter. -
timeWithExemplar
Liketime(Runnable)
, but additionally create an exemplar.See
observeWithExemplar(double, Map)
for documentation on theexemplarLabels
parameter. -
time
Executes callable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run.- Parameters:
timeable
- Code that is being timed- Returns:
- Result returned by callable.
-
timeWithExemplar
Liketime(Callable)
, but additionally create an exemplar.See
observeWithExemplar(double, String...)
for documentation on theexemplarLabels
parameter. -
timeWithExemplar
Liketime(Callable)
, but additionally create an exemplar.See
observeWithExemplar(double, Map)
for documentation on theexemplarLabels
parameter. -
observe
public void observe(double amt) Observe the given amount.- Parameters:
amt
- in most cases amt should be >= 0. Negative values are supported, but you should read https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations for implications and alternatives.
-
observeWithExemplar
Likeobserve(double)
, but additionally creates an exemplar.This exemplar takes precedence over any exemplar returned by the
HistogramExemplarSampler
configured inExemplarConfig
.The exemplar will have
amt
as the value,System.currentTimeMillis()
as the timestamp, and the specified labels.- Parameters:
amt
- same as inobserve(double)
(double)}exemplarLabels
- list of name/value pairs, as documented inExemplar(double, String...)
. A commonly used name is"trace_id"
. CallingobserveWithExemplar(amt)
means that an exemplar without labels is created. CallingobserveWithExemplar(amt, (String[]) null)
is equivalent to callingobserve(amt)
.
-
observeWithExemplar
LikeobserveWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
. -
updateExemplar
-
sampleNextExemplar
-
startTimer
Start a timer to track a duration.Call
Histogram.Timer.observeDuration()
at the end of what you want to measure the duration of. -
get
Get the value of the Histogram.Warning: The definition of
Histogram.Child.Value
is subject to change.
-