3#include "util/prometheus/Label.hpp"
4#include "util/prometheus/MetricBase.hpp"
5#include "util/prometheus/MetricBuilder.hpp"
6#include "util/prometheus/OStream.hpp"
12#include <unordered_map>
15namespace util::prometheus {
22 static std::unique_ptr<MetricBuilderInterface>
35 std::optional<std::string> description,
56 getMetric(
Labels labels, std::vector<std::int64_t>
const& buckets = {});
98 std::optional<std::string> description_;
99 std::unordered_map<std::string, std::unique_ptr<MetricBase>> metrics_;
103 template <
typename ValueType>
104 requires std::same_as<ValueType, std::int64_t> || std::same_as<ValueType, double>
106 getMetricImpl(
Labels labels, std::vector<ValueType>
const& buckets);
Class representing a collection of Prometheus labels.
Definition Label.hpp:41
Base class for a Prometheus metric containing a name and labels.
Definition MetricBase.hpp:12
Class representing a collection of Prometheus metric with the same name and type.
Definition MetricsFamily.hpp:20
MetricType type() const
Get the description of the metrics.
Definition MetricsFamily.cpp:70
MetricsFamily(std::string name, std::optional< std::string > description, MetricType type, MetricBuilderInterface &builder= *defaultMetricBuilder)
Construct a new MetricsFamily object.
Definition MetricsFamily.cpp:22
std::string const & name() const
Get the name of the metrics.
Definition MetricsFamily.cpp:64
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:36
friend OStream & operator<<(OStream &stream, MetricsFamily const &metricsFamily)
Serialize the metrics to a string in Prometheus format as one block.
Definition MetricsFamily.cpp:49
static std::unique_ptr< MetricBuilderInterface > defaultMetricBuilder
Definition MetricsFamily.hpp:23
A stream that can optionally compress its data.
Definition OStream.hpp:12
Interface to create a metric.
Definition MetricBuilder.hpp:15