RTC Toolkit  2.0.0
Classes | Public Types | Public Member Functions | List of all members
rtctk::componentFramework::ComponentMetrics Class Reference

Implementation of ComponentMetricsIf. More...

#include <componentMetrics.hpp>

Inheritance diagram for rtctk::componentFramework::ComponentMetrics:
rtctk::componentFramework::ComponentMetricsIf

Classes

struct  Thread
 

Public Types

using CounterTypes = perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 >
 Defines standard performance counter types: More...
 
using CounterVariant = typename CounterTypes::CounterVariant
 std::variant of pointers to each supported type in CounterTypes. More...
 
- Public Types inherited from rtctk::componentFramework::ComponentMetricsIf
using CounterTypes = perfc::CounterTypes< perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64 >
 Defines standard performance counter types: More...
 
using CounterVariant = typename CounterTypes::CounterVariant
 std::variant of pointers to each supported type in CounterTypes. More...
 

Public Member Functions

 ComponentMetrics (std::shared_ptr< OldbIf > oldb, DataPointPath root, log4cplus::Logger logger, ComponentMetricsParams const &initial_params={})
 
 ~ComponentMetrics () noexcept
 Destructor will automatically stop monitoring. More...
 
void StartMonitoring () override
 Start monitoring and publishing metrics. More...
 
void StopMonitoring () noexcept override
 Stop monitoring. More...
 
bool IsMonitoring () noexcept override
 Query whether monitoring is active. More...
 
void UpdateParams (ComponentMetricsParams const &params) override
 Updates parameters from params. More...
 
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 the register. More...
 
bool RemoveCounter (CounterVariant counter) override
 Remove counter from register. More...
 
void AddThread (pid_t pid, ThreadMetricInfo info) override
 Add a thread to be included in component metrics. More...
 
void RemoveThread (pid_t thread) override
 Remove previously registered thread. More...
 
- Public Member Functions inherited from rtctk::componentFramework::ComponentMetricsIf
virtual ~ComponentMetricsIf () noexcept=default
 

Detailed Description

Implementation of ComponentMetricsIf.

Telemetry metrics are published to OLDB using a common root specified during construction:

Member Typedef Documentation

◆ CounterTypes

using rtctk::componentFramework::ComponentMetricsIf::CounterTypes = perfc::CounterTypes<perfc::CounterDouble, perfc::CounterU64, perfc::CounterI64>

Defines standard performance counter types:

  • Double without timestamp
  • Unsigned 64bit integer without timestamp.
  • Signed 64bit integer without timestamp.

◆ CounterVariant

using rtctk::componentFramework::ComponentMetricsIf::CounterVariant = typename CounterTypes::CounterVariant

std::variant of pointers to each supported type in CounterTypes.

I.e.: std::variant<perfc::CounterDouble*, ...>

Constructor & Destructor Documentation

◆ ComponentMetrics()

rtctk::componentFramework::ComponentMetrics::ComponentMetrics ( std::shared_ptr< OldbIf oldb,
DataPointPath  root,
log4cplus::Logger  logger,
ComponentMetricsParams const &  initial_params = {} 
)
explicit
Parameters
oldbInterface used to publish metrics.
rootPath to the root where all metrics will be published.
loggerLogger instance to use.
initial_paramsinitial parameters. If unspecified the poll intervals is set to 5s and thread nice to 5.

◆ ~ComponentMetrics()

rtctk::componentFramework::ComponentMetrics::~ComponentMetrics ( )
noexcept

Destructor will automatically stop monitoring.

Member Function Documentation

◆ AddCounter()

perfc::ScopedRegistration rtctk::componentFramework::ComponentMetrics::AddCounter ( CounterVariant  counter,
CounterMetricInfo  info 
)
overridevirtual

Add a counter to be included in component metrics, identified by its address, together with info to the register.

Precondition
counter must point to a valid counter object.
Note
The caller must ensure that the counter is deregistered before the counter is deleted. The returned RAII object aims to facilitate this by unregistering on destruction.
Parameters
counterPointer to any of the supported counter types.
infoA info object to be associated with counter.
Returns
Non-empty RAII registration management object that automatically deregisters the counter when destroyed (or manually released).
Exceptions
MetricConflictExceptionif counter with same address has already been added before.
MetricConflictExceptionif another counter has been added with the same CounterMetricInfo::GetId().
RtctkExceptionif other exceptions occurs (nested).

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ AddThread()

void rtctk::componentFramework::ComponentMetrics::AddThread ( pid_t  thread,
ThreadMetricInfo  info 
)
overridevirtual

Add a thread to be included in component metrics.

Thread will be automatically removed if thread is destroyed.

Note
The thread is identified by pid_t not a pthread_t.
Parameters
threadLinux thread identifier (not std::thread/pthread).
infoAssociated information about thread.
Exceptions
MetricConflictExceptionif thread has been added before.
MetricConflictExceptionif another thread has been added with the same ThreadMetricInfo::GetId().

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ IsMonitoring()

bool rtctk::componentFramework::ComponentMetrics::IsMonitoring ( )
overridevirtualnoexcept

Query whether monitoring is active.

Returns
true if service is currently monitoring and publishing metrics.
false otherwise.

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ RemoveCounter()

bool rtctk::componentFramework::ComponentMetrics::RemoveCounter ( CounterVariant  counter)
overridevirtual

Remove counter from register.

Returns
true if counter was found and erased, false otherwise.

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ RemoveThread()

void rtctk::componentFramework::ComponentMetrics::RemoveThread ( pid_t  thread)
overridevirtual

Remove previously registered thread.

Parameters
threadThread id to remove.

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ StartMonitoring()

void rtctk::componentFramework::ComponentMetrics::StartMonitoring ( )
overridevirtual

Start monitoring and publishing metrics.

It has no effect if monitoring is already in-progress.

Synchronous setup in collaboration with parent thread.

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ StopMonitoring()

void rtctk::componentFramework::ComponentMetrics::StopMonitoring ( )
overridevirtualnoexcept

Stop monitoring.

Has no effect if no monitoring is active.

Implements rtctk::componentFramework::ComponentMetricsIf.

◆ UpdateParams()

void rtctk::componentFramework::ComponentMetrics::UpdateParams ( ComponentMetricsParams const &  params)
overridevirtual

Updates parameters from params.

There is no guarantee that parameters are applied synchronously. For example if monitoring is already active an update of polling interval could be applied when scheduling next interval.

Parameters
paramsParameters to update. Only members containing a value are considered.

Implements rtctk::componentFramework::ComponentMetricsIf.


The documentation for this class was generated from the following files: