3 #include <prometheus/exposer.h>
4 #include <prometheus/gauge.h>
5 #include <prometheus/registry.h>
18 MetricsService(
const std::string& host, uint16_t port, uint16_t polling_interval_ms);
37 auto metrics =
metrics_.find(T::group_name);
39 auto emplace_result =
metrics_.emplace(T::group_name, std::make_shared<T>(
registry_)).first;
40 metrics = emplace_result;
42 return dynamic_pointer_cast<T>(metrics->second);
49 std::map<std::string, SharedMetricsGroup>
metrics_;
class for metrics collecting. Registering specific metrics classes and creating prometheus server(exp...
Definition: metrics_service.hpp:16
const uint16_t kPollingIntervalMs
Definition: metrics_service.hpp:46
~MetricsService()
Definition: metrics_service.cpp:18
std::unique_ptr< prometheus::Exposer > exposer_
Definition: metrics_service.hpp:47
void start()
method to start thread that collecting data from special classes
Definition: metrics_service.cpp:23
std::unique_ptr< std::thread > thread_
Definition: metrics_service.hpp:50
std::shared_ptr< T > getMetrics()
method to get specific metrics instance. Creates and registers instance if it is called for first tim...
Definition: metrics_service.hpp:33
std::shared_ptr< prometheus::Registry > registry_
Definition: metrics_service.hpp:48
std::map< std::string, SharedMetricsGroup > metrics_
Definition: metrics_service.hpp:49
MetricsService(const std::string &host, uint16_t port, uint16_t polling_interval_ms)
Definition: metrics_service.cpp:11