Prometheus Client Library for Modern C++
Public Member Functions | Static Public Attributes | List of all members
prometheus::Gauge Class Reference

A gauge metric to represent a value that can arbitrarily go up and down. More...

Public Member Functions

 Gauge ()=default
 Create a gauge that starts at 0.
 
 Gauge (double)
 Create a gauge that starts at the given amount.
 
void Increment ()
 Increment the gauge by 1.
 
void Increment (double)
 Increment the gauge by the given amount.
 
void Decrement ()
 Decrement the gauge by 1.
 
void Decrement (double)
 Decrement the gauge by the given amount.
 
void Set (double)
 Set the gauge to the given value.
 
void SetToCurrentTime ()
 Set the gauge to the current unix time in seconds.
 
double Value () const
 Get the current value of the gauge.
 
ClientMetric Collect () const
 Get the current value of the gauge. More...
 

Static Public Attributes

static const MetricType metric_type {MetricType::Gauge}
 

Detailed Description

A gauge metric to represent a value that can arbitrarily go up and down.

The class represents the metric type gauge: https://prometheus.io/docs/concepts/metric_types/#gauge

Gauges are typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of running processes.

The class is thread-safe. No concurrent call to any API of this type causes a data race.

Member Function Documentation

◆ Collect()

ClientMetric prometheus::Gauge::Collect ( ) const

Get the current value of the gauge.

Collect is called by the Registry when collecting metrics.