Go to the documentation of this file.
11 #ifndef RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICS_HPP
12 #define RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICS_HPP
14 #include <condition_variable>
18 #include <log4cplus/logger.h>
51 std::shared_ptr<RepositoryIf> repo,
53 log4cplus::Logger logger,
54 std::chrono::seconds interval = std::chrono::seconds(10));
58 void ConfigurationLoop();
60 std::weak_ptr<ComponentMetricsIf> m_service;
61 std::shared_ptr<RepositoryIf> m_repo;
63 const std::chrono::seconds m_interval;
66 std::condition_variable m_cond;
69 log4cplus::Logger m_logger;
103 log4cplus::Logger logger,
115 [[nodiscard]]
virtual perfc::ScopedRegistration
133 std::chrono::milliseconds counter_poll_interval = std::chrono::milliseconds(5000);
134 std::chrono::milliseconds thread_poll_interval = std::chrono::milliseconds(5000);
138 struct MonitoringThread {
139 MonitoringThread(std::thread t) : stop_flag(false), id(0), thread(
std::move(t)) {
158 void MonitoringLoop();
163 std::shared_ptr<OldbIf> m_oldb;
164 DataPointPath m_root;
173 std::recursive_mutex m_api_mtx;
180 std::mutex m_mon_mtx;
186 std::condition_variable m_cond;
193 perfc::Register<CounterTypes, CounterMetricInfo> m_counters;
194 std::vector<Thread> m_threads;
195 std::optional<MonitoringThread> m_monitoring_thread;
196 log4cplus::Logger m_logger;
201 #endif // RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICS_HPP
void StartMonitoring() override
Start monitoring and publishing metrics.
Definition: componentMetrics.cpp:355
void UpdateParams(ComponentMetricsParams const ¶ms) override
Updates parameters from params.
Definition: componentMetrics.cpp:406
Defines auxiliary information associated with each thread registered with ComponentMetricsIf.
Definition: componentMetricsIf.hpp:80
Header file for ComponentMetricsIf.
Definition: commandReplier.cpp:20
Dynamic parameters for ComponentMetrics.
Definition: componentMetricsIf.hpp:112
virtual 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:421
void StopMonitoring() noexcept override
Stop monitoring.
Definition: componentMetrics.cpp:384
ThreadMetricInfo info
Definition: componentMetrics.hpp:124
typename CounterTypes::CounterVariant CounterVariant
std::variant of pointers to each supported type in CounterTypes.
Definition: componentMetricsIf.hpp:236
void AddThread(pid_t pid, ThreadMetricInfo info) override
Add a thread to be included in component metrics.
Definition: componentMetrics.cpp:466
bool IsMonitoring() noexcept override
Query whether monitoring is active.
Definition: componentMetrics.cpp:400
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition: componentMetricsIf.hpp:42
perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 > CounterTypes
Defines standard performance counter types:
Definition: componentMetricsIf.hpp:230
Component metrics interface.
Definition: componentMetricsIf.hpp:177
pid_t pid
Definition: componentMetrics.hpp:123
Configures ComponentMetrics from a runtime repository.
Definition: componentMetrics.hpp:39
ComponentMetricsConfigurator(std::weak_ptr< ComponentMetricsIf > service, std::shared_ptr< RepositoryIf > repo, DataPointPath root, log4cplus::Logger logger, std::chrono::seconds interval=std::chrono::seconds(10))
Constructs configuration with provided arguments.
Definition: componentMetrics.cpp:237
bool RemoveCounter(CounterVariant counter) override
Remove counter from register.
Definition: componentMetrics.cpp:460
Definition: mudpiProcessingError.hpp:119
void RemoveThread(pid_t thread) override
Remove previously registered thread.
Definition: componentMetrics.cpp:495
ComponentMetrics(std::shared_ptr< OldbIf > oldb, DataPointPath root, log4cplus::Logger logger, ComponentMetricsParams const &initial_params={})
Definition: componentMetrics.cpp:343
Header file for DataPointPath.
~ComponentMetricsConfigurator() noexcept
Definition: componentMetrics.cpp:332
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:65
~ComponentMetrics() noexcept
Destructor will automatically stop monitoring.
Definition: componentMetrics.cpp:351
Definition: componentMetrics.hpp:122
Implementation of ComponentMetricsIf.
Definition: componentMetrics.hpp:88