22#include "util/prometheus/Label.hpp"
23#include "util/prometheus/MetricBase.hpp"
24#include "util/prometheus/MetricBuilder.hpp"
25#include "util/prometheus/OStream.hpp"
31#include <unordered_map>
34namespace util::prometheus {
53 std::optional<std::string> description,
73 getMetric(
Labels labels, std::vector<std::int64_t>
const& buckets = {});
114 std::optional<std::string> description_;
115 std::unordered_map<std::string, std::unique_ptr<MetricBase>> metrics_;
119 template <
typename ValueType>
120 requires std::same_as<ValueType, std::int64_t> || std::same_as<ValueType, double>
122 getMetricImpl(
Labels labels, std::vector<ValueType>
const& buckets);
Class representing a collection of Prometheus labels.
Definition Label.hpp:59
Base class for a Prometheus metric containing a name and labels.
Definition MetricBase.hpp:31
Class representing a collection of Prometheus metric with the same name and type.
Definition MetricsFamily.hpp:39
MetricType type() const
Get the description of the metrics.
Definition MetricsFamily.cpp:85
MetricsFamily(std::string name, std::optional< std::string > description, MetricType type, MetricBuilderInterface &builder= *defaultMetricBuilder)
Construct a new MetricsFamily object.
Definition MetricsFamily.cpp:40
std::string const & name() const
Get the name of the metrics.
Definition MetricsFamily.cpp:79
MetricBase & getMetric(Labels labels, std::vector< std::int64_t > const &buckets={})
Get the metric with the given labels. If it does not exist, it will be created.
Definition MetricsFamily.cpp:51
friend OStream & operator<<(OStream &stream, MetricsFamily const &metricsFamily)
Serialize the metrics to a string in Prometheus format as one block.
Definition MetricsFamily.cpp:64
static std::unique_ptr< MetricBuilderInterface > defaultMetricBuilder
Definition MetricsFamily.hpp:41
A stream that can optionally compress its data.
Definition OStream.hpp:31
Interface to create a metric.
Definition MetricBuilder.hpp:34