Class Gauge
- All Implemented Interfaces:
DataPoint
,GaugeDataPoint
,TimerApi
,Collector
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.Builder
builder()
static Gauge.Builder
builder
(PrometheusProperties config) collect()
Called when the Prometheus server scrapes metrics.double
get()
Get the current value.void
inc
(double amount) Addamount
.void
incWithExemplar
(double amount, Labels labels) Addamount
, and create a custom exemplar with the given labels.void
set
(double value) Set the gauge tovalue
.void
setWithExemplar
(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, removeIf
Methods inherited from class MetricWithFixedMetadata
getPrometheusName
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface GaugeDataPoint
dec, dec, decWithExemplar, decWithExemplar, inc, incWithExemplar, startTimer
Methods inherited from interface TimerApi
time, time, timeChecked
-
Method Details
-
inc
Description copied from interface:GaugeDataPoint
Addamount
.- Specified by:
inc
in interfaceGaugeDataPoint
-
get
Description copied from interface:GaugeDataPoint
Get the current value.- Specified by:
get
in interfaceGaugeDataPoint
-
incWithExemplar
Description copied from interface:GaugeDataPoint
Addamount
, and create a custom exemplar with the given labels.- Specified by:
incWithExemplar
in interfaceGaugeDataPoint
-
set
Description copied from interface:GaugeDataPoint
Set the gauge tovalue
.- Specified by:
set
in interfaceGaugeDataPoint
-
setWithExemplar
Description copied from interface:GaugeDataPoint
Set the gauge tovalue
, and create a custom exemplar with the given labels.- Specified by:
setWithExemplar
in interfaceGaugeDataPoint
-
collect
Description copied from interface:Collector
Called when the Prometheus server scrapes metrics.- Specified by:
collect
in interfaceCollector
- Overrides:
collect
in classStatefulMetric<GaugeDataPoint,
Gauge.DataPoint>
-
builder
-
builder
-