Package io.prometheus.client
Class Counter.Child
- java.lang.Object
-
- io.prometheus.client.Counter.Child
-
- Enclosing class:
- Counter
public static class Counter.Child extends java.lang.Object
The value of a single Counter.Warning: References to a Child become invalid after using
SimpleCollector.remove(java.lang.String...)
orSimpleCollector.clear()
,
-
-
Field Summary
Fields Modifier and Type Field Description private long
created
private java.util.concurrent.atomic.AtomicReference<Exemplar>
exemplar
private CounterExemplarSampler
exemplarSampler
private java.lang.Boolean
exemplarsEnabled
private DoubleAdder
value
-
Constructor Summary
Constructors Constructor Description Child()
Child(java.lang.Boolean exemplarsEnabled, CounterExemplarSampler exemplarSampler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
created()
Get the created time of the counter in milliseconds.double
get()
Get the value of the counter.private Exemplar
getExemplar()
void
inc()
Increment the counter by 1.void
inc(double amt)
Increment the counter by the given amount.void
incWithExemplar(double amt, java.lang.String... exemplarLabels)
Likeinc(double)
, but additionally creates an exemplar.void
incWithExemplar(double amt, java.util.Map<java.lang.String,java.lang.String> exemplarLabels)
Same asincWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
.void
incWithExemplar(java.lang.String... exemplarLabels)
Same asincWithExemplar(1, exemplarLabels)
.void
incWithExemplar(java.util.Map<java.lang.String,java.lang.String> exemplarLabels)
Same asincWithExemplar(1, exemplarLabels)
.private Exemplar
sampleNextExemplar(double amt, Exemplar prev)
private void
updateExemplar(double amt, Exemplar userProvidedExemplar)
-
-
-
Field Detail
-
value
private final DoubleAdder value
-
created
private final long created
-
exemplarsEnabled
private final java.lang.Boolean exemplarsEnabled
-
exemplarSampler
private final CounterExemplarSampler exemplarSampler
-
exemplar
private final java.util.concurrent.atomic.AtomicReference<Exemplar> exemplar
-
-
Constructor Detail
-
Child
public Child()
-
Child
public Child(java.lang.Boolean exemplarsEnabled, CounterExemplarSampler exemplarSampler)
-
-
Method Detail
-
inc
public void inc()
Increment the counter by 1.
-
incWithExemplar
public void incWithExemplar(java.lang.String... exemplarLabels)
Same asincWithExemplar(1, exemplarLabels)
.
-
incWithExemplar
public void incWithExemplar(java.util.Map<java.lang.String,java.lang.String> exemplarLabels)
Same asincWithExemplar(1, exemplarLabels)
.
-
inc
public void inc(double amt)
Increment the counter by the given amount.- Throws:
java.lang.IllegalArgumentException
- If amt is negative.
-
incWithExemplar
public void incWithExemplar(double amt, java.lang.String... exemplarLabels)
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
public void incWithExemplar(double amt, java.util.Map<java.lang.String,java.lang.String> exemplarLabels)
Same asincWithExemplar(double, String...)
, but the exemplar labels are passed as aMap
.
-
updateExemplar
private void updateExemplar(double amt, Exemplar userProvidedExemplar)
-
get
public double get()
Get the value of the counter.
-
getExemplar
private Exemplar getExemplar()
-
created
public long created()
Get the created time of the counter in milliseconds.
-
-