RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
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
21
23
30class MetricConflictException : public RtctkException {
32};
33
49public:
60 explicit CounterMetricInfo(std::string id, std::string description) noexcept;
61
73 explicit CounterMetricInfo(std::string id,
74 std::string description,
75 std::string field_name,
76 std::string unit = "") noexcept;
77
88 explicit CounterMetricInfo(std::string id,
89 std::string description,
90 InfluxTagMap tag_map) noexcept;
91
103 explicit CounterMetricInfo(std::string id,
104 std::string description,
105 InfluxTagMap tag_map,
106 std::string field_name,
107 std::string unit = "") noexcept;
108
112 const std::string& GetId() const noexcept {
113 return m_id;
114 }
115
118 const std::string& GetDescription() const noexcept {
119 return m_description;
120 }
121
125 const InfluxTagMap& GetTagMap() const noexcept {
126 return m_tag_map;
127 }
128
132 const std::string& GetFieldName() const noexcept {
133 return m_field_name;
134 }
135
139 const std::string& GetUnit() const noexcept {
140 return m_unit;
141 }
142
143private:
144 std::string m_id;
145 std::string m_description;
146 InfluxTagMap m_tag_map;
147 std::string m_field_name;
148 std::string m_unit;
149};
150
164public:
165 virtual ~ComponentMetricsIf() noexcept = default;
166
171
176 virtual void StartMonitoring() = 0;
177
183 virtual void StopMonitoring() noexcept = 0;
184
191 virtual bool IsMonitoring() noexcept = 0;
192
199 virtual void UpdateParams() = 0;
201
206
214 perfc::CounterTypes<perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64>;
221
243 [[nodiscard]] virtual perfc::ScopedRegistration
245
251 virtual bool RemoveCounter(CounterVariant counter) = 0;
253};
254
255struct Unit {
256 inline static constexpr std::string PERCENT = "%";
257 inline static constexpr std::string MICRO_SECONDS = "us";
258 inline static constexpr std::string HERTZ = "hz";
259};
260
261} // namespace rtctk::componentFramework
262
263#endif // RTCTK_COMPONENTFRAMEWORK_COMPONENTMETRICSIF_HPP
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
virtual void UpdateParams()=0
Reloads parameters.
virtual void StopMonitoring() noexcept=0
Stop monitoring.
virtual bool IsMonitoring() noexcept=0
Query whether monitoring is active.
perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 > CounterTypes
Defines standard performance counter types:
Definition componentMetricsIf.hpp:213
virtual void StartMonitoring()=0
Start monitoring and publishing metrics.
virtual ~ComponentMetricsIf() noexcept=default
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...
virtual bool RemoveCounter(CounterVariant counter)=0
Remove counter from register.
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition componentMetricsIf.hpp:48
const std::string & GetUnit() const noexcept
Definition componentMetricsIf.hpp:139
const std::string & GetDescription() const noexcept
Definition componentMetricsIf.hpp:118
const std::string & GetId() const noexcept
Definition componentMetricsIf.hpp:112
const std::string & GetFieldName() const noexcept
Definition componentMetricsIf.hpp:132
CounterMetricInfo(std::string id, std::string description) noexcept
Construct instance.
Definition componentMetricsIf.cpp:15
const InfluxTagMap & GetTagMap() const noexcept
Definition componentMetricsIf.hpp:125
Helper class for passing tags in Telegraf.
Definition influxTagMap.hpp:26
Exception indicating that a metric such as counter or thread conflicts with already known metrics.
Definition componentMetricsIf.hpp:30
RtctkException() noexcept
Definition exceptions.cpp:112
Provides macros and utilities for exception handling.
Helper class for working with InfluxDB tags.
Definition commandReplier.cpp:21
Definition componentMetricsIf.hpp:255
static constexpr std::string PERCENT
Definition componentMetricsIf.hpp:256
static constexpr std::string MICRO_SECONDS
Definition componentMetricsIf.hpp:257
static constexpr std::string HERTZ
Definition componentMetricsIf.hpp:258