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.ObjectThe 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 longcreatedprivate java.util.concurrent.atomic.AtomicReference<Exemplar>exemplarprivate CounterExemplarSamplerexemplarSamplerprivate java.lang.BooleanexemplarsEnabledprivate DoubleAddervalue
-
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 longcreated()Get the created time of the counter in milliseconds.doubleget()Get the value of the counter.private ExemplargetExemplar()voidinc()Increment the counter by 1.voidinc(double amt)Increment the counter by the given amount.voidincWithExemplar(double amt, java.lang.String... exemplarLabels)Likeinc(double), but additionally creates an exemplar.voidincWithExemplar(double amt, java.util.Map<java.lang.String,java.lang.String> exemplarLabels)Same asincWithExemplar(double, String...), but the exemplar labels are passed as aMap.voidincWithExemplar(java.lang.String... exemplarLabels)Same asincWithExemplar(1, exemplarLabels).voidincWithExemplar(java.util.Map<java.lang.String,java.lang.String> exemplarLabels)Same asincWithExemplar(1, exemplarLabels).private ExemplarsampleNextExemplar(double amt, Exemplar prev)private voidupdateExemplar(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
CounterExemplarSamplerconfigured inExemplarConfig.The exemplar will have
amtas 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.
-
-