RTC Toolkit  2.0.0
componentMetricsIf.hpp
Go to the documentation of this file.
1 
11 #ifndef RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICSIF_HPP
12 #define RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICSIF_HPP
13 #include <iosfwd>
14 #include <string>
15 #include <sys/types.h>
16 
17 #include <perfc/perfc.hpp>
18 
20 
21 namespace rtctk::componentFramework {
22 
29 };
30 
43 public:
49  explicit CounterMetricInfo(std::string id, std::string description) noexcept;
50 
54  std::string const& GetId() const noexcept {
55  return m_id;
56  }
60  std::string const& GetDescription() const noexcept {
61  return m_description;
62  }
63 
64 private:
65  std::string m_id;
66  std::string m_description;
67 };
68 
81 public:
87  explicit ThreadMetricInfo(std::string id, std::string description) noexcept;
88 
92  std::string const& GetId() const noexcept {
93  return m_id;
94  }
98  std::string const& GetDescription() const noexcept {
99  return m_description;
100  }
101 
102 private:
103  std::string m_id;
104  std::string m_description;
105 };
106 
116  std::optional<std::chrono::milliseconds> counter_poll_interval;
117 
121  std::optional<std::chrono::milliseconds> thread_poll_interval;
122 
128  std::optional<int> monitor_thread_nice;
129 };
130 
141 bool operator==(ComponentMetricsParams const& lhs, ComponentMetricsParams const& rhs) noexcept;
152 bool operator!=(ComponentMetricsParams const& lhs, ComponentMetricsParams const& rhs) noexcept;
153 
163 std::ostream& operator<<(std::ostream& os, ComponentMetricsParams const& params);
164 
178 public:
179  virtual ~ComponentMetricsIf() noexcept = default;
180 
184 
190  virtual void StartMonitoring() = 0;
191 
197  virtual void StopMonitoring() noexcept = 0;
198 
205  virtual bool IsMonitoring() noexcept = 0;
206 
215  virtual void UpdateParams(ComponentMetricsParams const& params) = 0;
217 
221 
229  using CounterTypes =
230  perfc::CounterTypes<perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64>;
237 
258  [[nodiscard]] virtual perfc::ScopedRegistration
260 
266  virtual bool RemoveCounter(CounterVariant counter) = 0;
268 
272 
287  virtual void AddThread(pid_t thread, ThreadMetricInfo info) = 0;
288 
294  virtual void RemoveThread(pid_t thread) = 0;
296 };
297 
298 } // namespace rtctk::componentFramework
299 
300 #endif // RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICSIF_HPP
rtctk::componentFramework::ComponentMetricsIf::RemoveCounter
virtual bool RemoveCounter(CounterVariant counter)=0
Remove counter from register.
exceptions.hpp
Provides macros and utilities for exception handling.
rtctk::componentFramework::ThreadMetricInfo
Defines auxiliary information associated with each thread registered with ComponentMetricsIf.
Definition: componentMetricsIf.hpp:80
rtctk::componentFramework::ComponentMetricsIf::AddCounter
virtual perfc::ScopedRegistration AddCounter(CounterVariant counter, CounterMetricInfo info)=0
Add a counter to be included in component metrics, identified by its address, together with info to t...
rtctk::componentFramework::ComponentMetricsIf::StopMonitoring
virtual void StopMonitoring() noexcept=0
Stop monitoring.
rtctk::componentFramework::RtctkException::RtctkException
RtctkException() noexcept
Definition: exceptions.cpp:99
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::ComponentMetricsParams
Dynamic parameters for ComponentMetrics.
Definition: componentMetricsIf.hpp:112
rtctk::componentFramework::ComponentMetricsIf::UpdateParams
virtual void UpdateParams(ComponentMetricsParams const &params)=0
Updates parameters from params.
rtctk::componentFramework::ComponentMetricsIf::CounterVariant
typename CounterTypes::CounterVariant CounterVariant
std::variant of pointers to each supported type in CounterTypes.
Definition: componentMetricsIf.hpp:236
rtctk::componentFramework::RtctkException
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:207
rtctk::componentFramework::ComponentMetricsIf::AddThread
virtual void AddThread(pid_t thread, ThreadMetricInfo info)=0
Add a thread to be included in component metrics.
rtctk::componentFramework::operator<<
std::ostream & operator<<(std::ostream &os, AlertServiceIf::AlertStatus const &status)
Definition: alertServiceIf.cpp:59
rtctk::componentFramework::CounterMetricInfo
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition: componentMetricsIf.hpp:42
rtctk::componentFramework::ComponentMetricsParams::counter_poll_interval
std::optional< std::chrono::milliseconds > counter_poll_interval
Configures interval used between reading and publishing current counter metrics.
Definition: componentMetricsIf.hpp:116
rtctk::componentFramework::ComponentMetricsIf::CounterTypes
perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 > CounterTypes
Defines standard performance counter types:
Definition: componentMetricsIf.hpp:230
rtctk::componentFramework::ComponentMetricsIf
Component metrics interface.
Definition: componentMetricsIf.hpp:177
rtctk::componentFramework::ComponentMetricsIf::~ComponentMetricsIf
virtual ~ComponentMetricsIf() noexcept=default
rtctk::componentFramework::MetricConflictException
Exception indicating that a metric such as counter or thread conflicts with already known metrics.
Definition: componentMetricsIf.hpp:27
rtctk::componentFramework::operator!=
constexpr bool operator!=(const MatrixBuffer< T, A > &lhs, const MatrixBuffer< T, A > &rhs) noexcept
Compares two MatrixBuffer objects and returns true if they do not have the same shape or the elements...
Definition: matrixBuffer.hpp:119
rtctk::componentFramework::ThreadMetricInfo::GetId
std::string const & GetId() const noexcept
Definition: componentMetricsIf.hpp:92
rtctk::componentFramework::ThreadMetricInfo::ThreadMetricInfo
ThreadMetricInfo(std::string id, std::string description) noexcept
Construct instance.
Definition: componentMetricsIf.cpp:19
rtctk::componentFramework::ComponentMetricsIf::RemoveThread
virtual void RemoveThread(pid_t thread)=0
Remove previously registered thread.
rtctk::componentFramework::CounterMetricInfo::GetDescription
std::string const & GetDescription() const noexcept
Definition: componentMetricsIf.hpp:60
rtctk::componentFramework::ComponentMetricsIf::StartMonitoring
virtual void StartMonitoring()=0
Start monitoring and publishing metrics.
rtctk::componentFramework::CounterMetricInfo::GetId
std::string const & GetId() const noexcept
Definition: componentMetricsIf.hpp:54
rtctk::componentFramework::ComponentMetricsParams::monitor_thread_nice
std::optional< int > monitor_thread_nice
Configures nice value of telemetry monitoring thread.
Definition: componentMetricsIf.hpp:128
rtctk::componentFramework::ThreadMetricInfo::GetDescription
std::string const & GetDescription() const noexcept
Definition: componentMetricsIf.hpp:98
rtctk::componentFramework::operator==
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:306
rtctk::componentFramework::CounterMetricInfo::CounterMetricInfo
CounterMetricInfo(std::string id, std::string description) noexcept
Construct instance.
Definition: componentMetricsIf.cpp:15
rtctk::componentFramework::ComponentMetricsParams::thread_poll_interval
std::optional< std::chrono::milliseconds > thread_poll_interval
Configures interval used between reading and publishing current thread metrics.
Definition: componentMetricsIf.hpp:121
rtctk::componentFramework::ComponentMetricsIf::IsMonitoring
virtual bool IsMonitoring() noexcept=0
Query whether monitoring is active.
rtctk_config_tool.default
default
Enter an interactive shell.
Definition: rtctk_config_tool.py:119