11#ifndef RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICS_HPP
12#define RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICS_HPP
14#include <condition_variable>
18#include <log4cplus/logger.h>
70 log4cplus::Logger logger,
83 [[nodiscard]] perfc::ScopedRegistration
88 struct MonitoringThread {
89 explicit MonitoringThread(std::thread t) : thread(
std::move(t)) {
94 bool stop_flag =
false;
108 void MonitoringLoop();
114 DataPointPath m_oldb_root;
119 RuntimeRepoIf& m_rtr;
120 DataPointPath m_rtr_root;
129 std::recursive_mutex m_api_mtx;
136 std::mutex m_mon_mtx;
142 std::condition_variable m_cond;
149 perfc::Register<CounterTypes, CounterMetricInfo> m_counters;
150 std::optional<MonitoringThread> m_monitoring_thread;
151 log4cplus::Logger m_logger;
152 TelegrafAdapter* m_telegraf_adapter;
Component metrics interface.
Definition componentMetricsIf.hpp:163
typename CounterTypes::CounterVariant CounterVariant
std::variant of pointers to each supported type in CounterTypes.
Definition componentMetricsIf.hpp:220
perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 > CounterTypes
Defines standard performance counter types:
Definition componentMetricsIf.hpp:213
typename CounterTypes::CounterVariant CounterVariant
std::variant of pointers to each supported type in CounterTypes.
Definition componentMetricsIf.hpp:220
void StopMonitoring() noexcept override
Stop monitoring.
Definition componentMetrics.cpp:234
Parameters GetParams()
Definition componentMetrics.cpp:290
bool RemoveCounter(CounterVariant counter) override
Remove counter from register.
Definition componentMetrics.cpp:340
perfc::ScopedRegistration AddCounter(CounterVariant counter, CounterMetricInfo info) override
Add a counter to be included in component metrics, identified by its address, together with info to t...
Definition componentMetrics.cpp:295
bool IsMonitoring() noexcept override
Query whether monitoring is active.
Definition componentMetrics.cpp:250
~ComponentMetrics() noexcept override
Destructor will automatically stop monitoring.
Definition componentMetrics.cpp:201
void StartMonitoring() override
Start monitoring and publishing metrics.
Definition componentMetrics.cpp:205
ComponentMetrics(OldbIf &oldb, DataPointPath oldb_root, RuntimeRepoIf &rtr, DataPointPath rtr_root, log4cplus::Logger logger, TelegrafAdapter *telegraf_adapter=nullptr)
Construct new metrics object.
Definition componentMetrics.cpp:186
void UpdateParams() override
Reloads parameters.
Definition componentMetrics.cpp:256
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition componentMetricsIf.hpp:48
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
Base interface for all OLDB adapters.
Definition oldbIf.hpp:24
Abstract interface providing basic read and write facilities to a repository.
Definition repositoryIf.hpp:50
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:26
Implementation of the Telegraf Adapter.
Definition telegrafAdapter.hpp:93
Header file for ComponentMetricsIf.
Header file for DataPointPath.
Definition commandReplier.cpp:21
Definition ddsSub.hpp:155
Runtime parameters.
Definition componentMetrics.hpp:52
int thread_nice
Definition componentMetrics.hpp:54
std::chrono::milliseconds counter_poll_interval
Definition componentMetrics.hpp:53
Header file needed to instantiate an TelegrafAdapter.