22#include "util/prometheus/MetricBase.hpp"
23#include "util/prometheus/OStream.hpp"
24#include "util/prometheus/impl/AnyCounterBase.hpp"
31namespace util::prometheus {
38template <SomeNumberType NumberType>
40 using ValueType = NumberType;
50 template <impl::SomeCounterImpl ImplType = impl::CounterImpl<ValueType>>
51 requires std::same_as<ValueType, typename std::remove_cvref_t<ImplType>::ValueType>
54 , impl::AnyCounterBase<ValueType>(std::forward<ImplType>(impl))
66 this->pimpl_->add(ValueType{1});
78 this->pimpl_->add(ValueType{-1});
91 this->pimpl_->add(
value);
104 this->pimpl_->add(-
value);
116 this->pimpl_->set(
value);
127 return this->pimpl_->value();
145using GaugeInt = AnyGauge<std::int64_t>;
150using GaugeDouble = AnyGauge<double>;
Base class for a Prometheus metric containing a name and labels.
Definition MetricBase.hpp:31
std::string const & name() const
Get the name of the metric.
Definition MetricBase.cpp:67
std::string const & labelsString() const
Get the labels of the metric in serialized format, e.g. {name="value",name2="value2"}...
Definition MetricBase.cpp:73
A stream that can optionally compress its data.
Definition OStream.hpp:31
Definition AnyCounterBase.hpp:32
A prometheus gauge metric implementation. It can be increased, decreased or set to a value.
Definition Gauge.hpp:39
void set(ValueType const value)
Set the gauge to the given value.
Definition Gauge.hpp:114
AnyGauge(std::string name, std::string labelsString, ImplType &&impl=ImplType{})
Construct a new AnyGauge object.
Definition Gauge.hpp:52
AnyGauge & operator--()
Decrease the gauge by one.
Definition Gauge.hpp:76
AnyGauge & operator++()
Increase the gauge by one.
Definition Gauge.hpp:64
AnyGauge & operator-=(ValueType const value)
Decrease the gauge by the given value.
Definition Gauge.hpp:102
AnyGauge & operator+=(ValueType const value)
Increase the gauge by the given value.
Definition Gauge.hpp:89
void serializeValue(OStream &stream) const override
Serialize the counter to a string in prometheus format (i.e. name{labels} value)
Definition Gauge.hpp:136
ValueType value() const
Get the value of the counter.
Definition Gauge.hpp:125