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>
22 static std::unique_ptr<MetricBuilderInterface>
35 std::optional<std::string> description,
56 getMetric(
Labels labels, std::vector<std::int64_t>
const& buckets = {});
86 [[nodiscard]] std::string
const&
99 std::optional<std::string> description_;
100 std::unordered_map<std::string, std::unique_ptr<MetricBase>> metrics_;
104 template <
typename ValueType>
105 requires std::same_as<ValueType, std::int64_t> || std::same_as<ValueType, double>
107 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
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
MetricsFamily(std::string name, std::optional< std::string > description, MetricType type, MetricBuilderInterface &metricBuilder= *defaultMetricBuilder)
Construct a new MetricsFamily object.
Definition MetricsFamily.cpp:22
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
The default metric builder.
Definition MetricsFamily.hpp:23
A stream that can optionally compress its data.
Definition OStream.hpp:12
Prometheus metrics: counters, gauges, histograms and their registry and serialization.
Definition Bool.hpp:12
MetricType
The kind and value type of a Prometheus metric.
Definition MetricBase.hpp:72
Interface to create a metric.
Definition MetricBuilder.hpp:15