3 #include <prometheus/gauge.h>
4 #include <prometheus/registry.h>
13 #define ADD_GAUGE_METRIC(method, name, description) \
14 void method(double v) { \
15 static auto& label = addMetric<prometheus::Gauge>(group_name + "_" + name, description).Add({}); \
24 #define ADD_UPDATER_METHOD(method) \
25 void method##Updater(MetricGetter getter) { \
26 updaters_.push_back([this, getter]() { method(getter()); }); \
32 #define ADD_GAUGE_METRIC_WITH_UPDATER(method, name, description) \
33 ADD_GAUGE_METRIC(method, name, description) \
34 ADD_UPDATER_METHOD(method)
52 prometheus::Family<Type>&
addMetric(
const std::string& name,
const std::string& help) {
53 return prometheus::detail::Builder<Type>().Name(name).Help(help).Register(*
registry_);
Definition: metrics_group.hpp:36
std::vector< MetricUpdater > updaters_
Definition: metrics_group.hpp:66
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:52
std::function< double()> MetricGetter
Definition: metrics_group.hpp:38
void updateData()
method that is used to call registered updaters for the specific class
Definition: metrics_group.hpp:58
MetricsGroup(std::shared_ptr< prometheus::Registry > registry)
Definition: metrics_group.hpp:40
std::function< void()> MetricUpdater
Definition: metrics_group.hpp:39
std::shared_ptr< prometheus::Registry > registry_
Definition: metrics_group.hpp:65
virtual ~MetricsGroup()=default
std::hash for asio::adress
Definition: FixedHash.h:483
std::shared_ptr< MetricsGroup > SharedMetricsGroup
Definition: metrics_group.hpp:69