Class Gauge
- All Implemented Interfaces:
DataPoint, GaugeDataPoint, TimerApi, Collector
public class Gauge
extends StatefulMetric<GaugeDataPoint, Gauge.DataPoint>
implements GaugeDataPoint
Gauge metric.
Example usage:
Gauge currentActiveUsers = Gauge.builder()
.name("current_active_users")
.help("Number of users that are currently active")
.labelNames("region")
.register();
public void login(String region) {
currentActiveUsers.labelValues(region).inc();
// perform login
}
public void logout(String region) {
currentActiveUsers.labelValues(region).dec();
// perform logout
}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Gauge.Builderbuilder()static Gauge.Builderbuilder(PrometheusProperties config) collect()Called when the Prometheus server scrapes metrics.doubleget()Get the current value.voidinc(double amount) Addamount.voidincWithExemplar(double amount, Labels labels) Addamount, and create a custom exemplar with the given labels.voidset(double value) Set the gauge tovalue.voidsetWithExemplar(double value, Labels labels) Set the gauge tovalue, and create a custom exemplar with the given labels.Methods inherited from class StatefulMetric
clear, initLabelValues, labelValues, remove, removeIfMethods inherited from class MetricWithFixedMetadata
getPrometheusNameMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GaugeDataPoint
dec, dec, decWithExemplar, decWithExemplar, inc, incWithExemplar, startTimerMethods inherited from interface TimerApi
time, time, timeChecked
-
Method Details
-
inc
Description copied from interface:GaugeDataPointAddamount.- Specified by:
incin interfaceGaugeDataPoint
-
get
Description copied from interface:GaugeDataPointGet the current value.- Specified by:
getin interfaceGaugeDataPoint
-
incWithExemplar
Description copied from interface:GaugeDataPointAddamount, and create a custom exemplar with the given labels.- Specified by:
incWithExemplarin interfaceGaugeDataPoint
-
set
Description copied from interface:GaugeDataPointSet the gauge tovalue.- Specified by:
setin interfaceGaugeDataPoint
-
setWithExemplar
Description copied from interface:GaugeDataPointSet the gauge tovalue, and create a custom exemplar with the given labels.- Specified by:
setWithExemplarin interfaceGaugeDataPoint
-
collect
Description copied from interface:CollectorCalled when the Prometheus server scrapes metrics.- Specified by:
collectin interfaceCollector- Overrides:
collectin classStatefulMetric<GaugeDataPoint, Gauge.DataPoint>
-
builder
-
builder
-