Package io.prometheus.client
Class Gauge.Child
java.lang.Object
io.prometheus.client.Gauge.Child
- Enclosing class:
Gauge
The value of a single Gauge.
Warning: References to a Child become invalid after using
SimpleCollector.remove(java.lang.String...)
or SimpleCollector.clear()
,
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static Gauge.TimeProvider
private final DoubleAdder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
dec()
Decrement the gauge by 1.void
dec
(double amt) Decrement the gauge by the given amount.double
get()
Get the value of the gauge.void
inc()
Increment the gauge by 1.void
inc
(double amt) Increment the gauge by the given amount.void
set
(double val) Set the gauge to the given value.void
Set the gauge to the current unixtime.double
Executes runnable code (e.g.<E> E
Executes callable code (e.g.Start a timer to track a duration.
-
Field Details
-
value
-
timeProvider
-
-
Constructor Details
-
Child
public Child()
-
-
Method Details
-
inc
public void inc()Increment the gauge by 1. -
inc
public void inc(double amt) Increment the gauge by the given amount. -
dec
public void dec()Decrement the gauge by 1. -
dec
public void dec(double amt) Decrement the gauge by the given amount. -
set
public void set(double val) Set the gauge to the given value. -
setToCurrentTime
public void setToCurrentTime()Set the gauge to the current unixtime. -
startTimer
Start a timer to track a duration.Call
Gauge.Timer.setDuration()
at the end of what you want to measure the duration of.This is primarily useful for tracking the durations of major steps of batch jobs, which are then pushed to a PushGateway. For tracking other durations/latencies you should usually use a
Summary
. -
setToTime
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.
-
setToTime
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.
-
get
public double get()Get the value of the gauge.
-