3#include <prometheus/gauge.h>
4#include <prometheus/histogram.h>
5#include <prometheus/registry.h>
12#define ADD_GAUGE_METRIC(method, name, description) \
13 void method(double v) { \
14 static auto& label = addMetric<prometheus::Gauge>(group_name + "_" + name, description).Add({}); \
21#define ADD_HISTOGRAM_METRIC(method, name, description, buckets) \
22 void method(double v, std::map<std::string, std::string> labels) { \
23 static auto& label = addMetric<prometheus::Histogram>(group_name + "_" + name, description); \
24 label.Add(labels, prometheus::Histogram::BucketBoundaries{buckets.begin(), buckets.end()}).Observe(v); \
32#define ADD_UPDATER_METHOD(method) \
33 void method##Updater(MetricGetter getter) { \
34 updaters_.push_back([this, getter]() { method(getter()); }); \
40#define ADD_GAUGE_METRIC_WITH_UPDATER(method, name, description) \
41 ADD_GAUGE_METRIC(method, name, description) \
42 ADD_UPDATER_METHOD(method)
60 prometheus::Family<Type>&
addMetric(
const std::string& name,
const std::string& help) {
61 return prometheus::detail::Builder<Type>().Name(name).Help(help).Register(*
registry_);
Definition metrics_group.hpp:44
std::vector< MetricUpdater > updaters_
Definition metrics_group.hpp:74
std::function< double()> MetricGetter
Definition metrics_group.hpp:46
prometheus::Family< Type > & addMetric(const std::string &name, const std::string &help)
template method to add metric family. Family is a metric, but additional labels could be specified fo...
Definition metrics_group.hpp:60
void updateData()
method that is used to call registered updaters for the specific class
Definition metrics_group.hpp:66
MetricsGroup(std::shared_ptr< prometheus::Registry > registry)
Definition metrics_group.hpp:48
std::function< void()> MetricUpdater
Definition metrics_group.hpp:47
std::shared_ptr< prometheus::Registry > registry_
Definition metrics_group.hpp:73
virtual ~MetricsGroup()=default
std::hash for asio::adress
Definition FixedHash.h:483
Definition app_base.hpp:29
std::shared_ptr< MetricsGroup > SharedMetricsGroup
Definition metrics_group.hpp:77