Package io.prometheus.client
Class Counter.Child
java.lang.Object
io.prometheus.client.Counter.Child
- Enclosing class:
Counter
The value of a single Counter.
Warning: References to a Child become invalid after using
SimpleCollector.remove(java.lang.String...)
or SimpleCollector.clear()
,
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final AtomicReference
<Exemplar> private final CounterExemplarSampler
private final Boolean
private final DoubleAdder
-
Constructor Summary
ConstructorsConstructorDescriptionChild()
Child
(Boolean exemplarsEnabled, CounterExemplarSampler exemplarSampler) -
Method Summary
Modifier and TypeMethodDescriptionlong
created()
Get the created time of the counter in milliseconds.double
get()
Get the value of the counter.private Exemplar
void
inc()
Increment the counter by 1.void
inc
(double amt) Increment the counter by the given amount.void
incWithExemplar
(double amt, String... exemplarLabels) Likeinc(double)
, but additionally creates an exemplar.void
incWithExemplar
(double amt, Map<String, String> exemplarLabels) Same asincWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
.void
incWithExemplar
(String... exemplarLabels) Same asincWithExemplar(1, exemplarLabels)
.void
incWithExemplar
(Map<String, String> exemplarLabels) Same asincWithExemplar(1, exemplarLabels)
.private Exemplar
sampleNextExemplar
(double amt, Exemplar prev) private void
updateExemplar
(double amt, Exemplar userProvidedExemplar)
-
Field Details
-
value
-
created
private final long created -
exemplarsEnabled
-
exemplarSampler
-
exemplar
-
-
Constructor Details
-
Child
public Child() -
Child
-
-
Method Details
-
inc
public void inc()Increment the counter by 1. -
incWithExemplar
Same asincWithExemplar(1, exemplarLabels)
. -
incWithExemplar
Same asincWithExemplar(1, exemplarLabels)
. -
inc
public void inc(double amt) Increment the counter by the given amount.- Throws:
IllegalArgumentException
- If amt is negative.
-
incWithExemplar
Likeinc(double)
, but additionally creates an exemplar.This exemplar takes precedence over any exemplar returned by the
CounterExemplarSampler
configured inExemplarConfig
.The exemplar will have
amt
as the value,System.currentTimeMillis()
as the timestamp, and the specified labels.- Parameters:
amt
- same as ininc(double)
exemplarLabels
- list of name/value pairs, as documented inExemplar(double, String...)
. A commonly used name is"trace_id"
. CallingincWithExemplar(amt)
means that an exemplar without labels will be created. CallingincWithExemplar(amt, (String[]) null)
is equivalent to callinginc(amt)
.
-
incWithExemplar
Same asincWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
. -
updateExemplar
-
sampleNextExemplar
-
get
public double get()Get the value of the counter. -
getExemplar
-
created
public long created()Get the created time of the counter in milliseconds.
-