3#include "util/prometheus/MetricBase.hpp"
4#include "util/prometheus/OStream.hpp"
5#include "util/prometheus/impl/AnyCounterBase.hpp"
20template <SomeNumberType NumberType>
32 template <impl::SomeCounterImpl ImplType = impl::CounterImpl<ValueType>>
33 requires std::same_as<ValueType, typename std::remove_cvref_t<ImplType>::ValueType>
36 , impl::AnyCounterBase<
ValueType>(std::forward<ImplType>(impl))
73 this->pimpl_->add(
value);
86 this->pimpl_->add(-
value);
98 this->pimpl_->set(
value);
109 return this->pimpl_->value();
Base class for a Prometheus metric containing a name and labels.
Definition MetricBase.hpp:12
MetricBase(std::string name, std::string labelsString)
Construct a new MetricBase object.
Definition MetricBase.cpp:11
std::string const & name() const
Get the name of the metric.
Definition MetricBase.cpp:48
std::string const & labelsString() const
Get the labels of the metric in serialized format, e.g. {name="value",name2="value2"}...
Definition MetricBase.cpp:54
A stream that can optionally compress its data.
Definition OStream.hpp:12
Definition AnyCounterBase.hpp:13
Prometheus metrics: counters, gauges, histograms and their registry and serialization.
Definition Bool.hpp:12
AnyGauge< std::int64_t > GaugeInt
Alias for a gauge with a 64-bit integer value.
Definition Gauge.hpp:127
AnyGauge< double > GaugeDouble
Alias for a gauge with a double value.
Definition Gauge.hpp:132
A prometheus gauge metric implementation. It can be increased, decreased or set to a value.
Definition Gauge.hpp:21
void set(ValueType const value)
Set the gauge to the given value.
Definition Gauge.hpp:96
AnyGauge(std::string name, std::string labelsString, ImplType &&impl=ImplType{})
Construct a new AnyGauge object.
Definition Gauge.hpp:34
AnyGauge & operator--()
Decrease the gauge by one.
Definition Gauge.hpp:58
AnyGauge & operator++()
Increase the gauge by one.
Definition Gauge.hpp:46
AnyGauge & operator-=(ValueType const value)
Decrease the gauge by the given value.
Definition Gauge.hpp:84
AnyGauge & operator+=(ValueType const value)
Increase the gauge by the given value.
Definition Gauge.hpp:71
void serializeValue(OStream &stream) const override
Serialize the counter to a string in prometheus format (i.e. name{labels} value).
Definition Gauge.hpp:118
NumberType ValueType
The type of the gauge value.
Definition Gauge.hpp:22
ValueType value() const
Definition Gauge.hpp:107