Package io.prometheus.client
Class Gauge.Child
- java.lang.Object
-
- io.prometheus.client.Gauge.Child
-
- Enclosing class:
- Gauge
public static class Gauge.Child extends Object
The value of a single Gauge.Warning: References to a Child become invalid after using
SimpleCollector.remove(java.lang.String...)orSimpleCollector.clear(),
-
-
Constructor Summary
Constructors Constructor Description Child()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddec()Decrement the gauge by 1.voiddec(double amt)Decrement the gauge by the given amount.doubleget()Get the value of the gauge.voidinc()Increment the gauge by 1.voidinc(double amt)Increment the gauge by the given amount.voidset(double val)Set the gauge to the given value.voidsetToCurrentTime()Set the gauge to the current unixtime.doublesetToTime(Runnable timeable)Executes runnable code (e.g.<E> EsetToTime(Callable<E> timeable)Executes callable code (e.g.Gauge.TimerstartTimer()Start a timer to track a duration.
-
-
-
Constructor Detail
-
Child
public Child()
-
-
Method Detail
-
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
public Gauge.Timer 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
public double setToTime(Runnable timeable)
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
public <E> E setToTime(Callable<E> timeable)
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.
-
-