RTC Toolkit  2.0.0
Public Member Functions | List of all members
rtctk::componentFramework::ComponentMetricsIf Class Referenceabstract

Component metrics interface. More...

#include <componentMetricsIf.hpp>

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

Public Member Functions

virtual ~ComponentMetricsIf () noexcept=default
 
Configuration and control
virtual void StartMonitoring ()=0
 Start monitoring and publishing metrics. More...
 
virtual void StopMonitoring () noexcept=0
 Stop monitoring. More...
 
virtual bool IsMonitoring () noexcept=0
 Query whether monitoring is active. More...
 
virtual void UpdateParams (ComponentMetricsParams const &params)=0
 Updates parameters from params. More...
 
Thread Metrics
virtual void AddThread (pid_t thread, ThreadMetricInfo info)=0
 Add a thread to be included in component metrics. More...
 
virtual void RemoveThread (pid_t thread)=0
 Remove previously registered thread. More...
 

Performance Counter Metrics

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...
 
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 the register. More...
 
virtual bool RemoveCounter (CounterVariant counter)=0
 Remove counter from register. More...
 

Detailed Description

Component metrics interface.

Supports registration and monitoring of component metrics.

Supported types of metrics:

Thread Safety
thread-safe

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

◆ ~ComponentMetricsIf()

virtual rtctk::componentFramework::ComponentMetricsIf::~ComponentMetricsIf ( )
virtualdefaultnoexcept

Member Function Documentation

◆ AddCounter()

virtual perfc::ScopedRegistration rtctk::componentFramework::ComponentMetricsIf::AddCounter ( CounterVariant  counter,
CounterMetricInfo  info 
)
pure virtual

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).

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ AddThread()

virtual void rtctk::componentFramework::ComponentMetricsIf::AddThread ( pid_t  thread,
ThreadMetricInfo  info 
)
pure virtual

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().

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ IsMonitoring()

virtual bool rtctk::componentFramework::ComponentMetricsIf::IsMonitoring ( )
pure virtualnoexcept

Query whether monitoring is active.

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

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ RemoveCounter()

virtual bool rtctk::componentFramework::ComponentMetricsIf::RemoveCounter ( CounterVariant  counter)
pure virtual

Remove counter from register.

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

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ RemoveThread()

virtual void rtctk::componentFramework::ComponentMetricsIf::RemoveThread ( pid_t  thread)
pure virtual

Remove previously registered thread.

Parameters
threadThread id to remove.

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ StartMonitoring()

virtual void rtctk::componentFramework::ComponentMetricsIf::StartMonitoring ( )
pure virtual

Start monitoring and publishing metrics.

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

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ StopMonitoring()

virtual void rtctk::componentFramework::ComponentMetricsIf::StopMonitoring ( )
pure virtualnoexcept

Stop monitoring.

Has no effect if no monitoring is active.

Implemented in rtctk::componentFramework::ComponentMetrics.

◆ UpdateParams()

virtual void rtctk::componentFramework::ComponentMetricsIf::UpdateParams ( ComponentMetricsParams const &  params)
pure virtual

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.

Implemented in rtctk::componentFramework::ComponentMetrics.


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