MetroCollect  2.3.4
MetroCollect::MetricsController Class Reference

Class to control the collection of metrics. More...

#include <MetricsController.h>

Collaboration diagram for MetroCollect::MetricsController:

Classes

struct  MetricsStats
 Struct to store all final metric stats. More...
 
struct  MetricsStatsIntermediate
 Struct to store all intermediate metric stats. More...
 

Public Member Functions

 MetricsController (MetricsControllerDelegate &delegate) noexcept
 Construct a new Metrics Controller object. More...
 
MetricsControllerDelegatedelegate () const noexcept
 Returns the controller's delegate. More...
 
bool isCollecting () const noexcept
 Returns whether the controller is collecting metrics. More...
 
bool sendValues () const noexcept
 Returns whether the controller alerts the delegate after collecting new values. More...
 
bool sendStats () const noexcept
 Returns whether the controller alerts the delegate after computing statistics. More...
 
const std::vector< size_t > & requestedMetrics () const noexcept
 Returns the list of request metrics. More...
 
std::chrono::milliseconds samplingInterval () const noexcept
 Returns the metrics sampling interval. More...
 
size_t processingWindowLength () const noexcept
 Returns the length of the processing window used to compute statistics. More...
 
size_t processingWindowOverlap () const noexcept
 Returns the overlap of the processing window used to compute statistics. More...
 
bool convertToUnitsPerSeconds () const noexcept
 Returns whether to convert metric differences to units per second. More...
 
void setSendValues (bool sendValues) noexcept
 Sets whether the controller alerts the delegate after collecting new values. More...
 
void setSendStats (bool sendStats) noexcept
 Sets whether the controller alerts the delegate after computing statistics. More...
 
void setRequestedMetrics (const MetricsArray< Statistics::Stats > &requestedMetrics) noexcept
 Sets the list of request metrics. More...
 
void setSamplingInterval (std::chrono::milliseconds interval) noexcept
 Sets the metrics sampling interval. More...
 
void setProcessingWindow (size_t length, size_t overlap) noexcept
 Sets the processing window parameters used to compute statistics. More...
 
void setConvertToUnitsPerSeconds (bool convertToUnitsPerSecond) noexcept
 Sets whether to convert metric differences to units per second. More...
 
void collectMetrics ()
 Launch metric collection loop. More...
 
bool isMetricNull (size_t index) const
 Checks wether a metric is zero. More...
 

Static Public Attributes

static constexpr bool defaultSendValues = false
 Default parameter option. More...
 
static constexpr bool defaultSendStats = false
 Default parameter option. More...
 
static constexpr std::chrono::milliseconds defaultSamplingInterval = 100ms
 Default parameter option. More...
 
static constexpr size_t defaultProcessingWindowLength = 10
 Default parameter option. More...
 
static constexpr size_t defaultProcessingWindowOverlap = 0
 Default parameter option. More...
 
static constexpr bool defaultConvertToUnitsPerSecond = true
 Default parameter option. More...
 

Protected Member Functions

void updateMetrics ()
 Fetch latest metrics from source and compute their variations. More...
 
void updateIterativeStats ()
 Update iterative stats with new MetricsDiffArray. More...
 
void computeFinalStats ()
 Compute final stats at the end of processing window. More...
 
void resetIterativeStats ()
 Reset iterative stats to begin new processing window. More...
 

Protected Attributes

MetricsControllerDelegatedelegate_
 Delegate to alert when something happens. More...
 
MetricsSource::SourceInterests sourceInterests_
 Boolean arrays to store source interests. More...
 
std::vector< size_t > requestedMetrics_
 Indexes of metrics requested to be collected. More...
 
bool sendValues_
 Whether to give values to the delegate. More...
 
bool sendStats_
 Whether to compute stats and give them to the delegate. More...
 
bool isCollecting_
 Whether the receiver is collecting metrics. More...
 
std::chrono::milliseconds samplingInterval_
 Metrics sampling interval. More...
 
double unitsPerSecondFactor_
 Factor to convert metric differences to units per second. More...
 
bool convertToUnitsPerSecond_
 Whether to convert metric differences to units per second. More...
 
size_t processingWindowLength_
 Length of processing window used to compute statistics. More...
 
size_t processingWindowOverlap_
 Overlap of processing window used to compute statistics. More...
 
std::unique_ptr< MetricsDataArraycurrentMetrics_
 Pointer to latest metric raw values. More...
 
std::unique_ptr< MetricsDataArraypreviousMetrics_
 Pointer to earlier metric raw values. More...
 
CircularArray::CircularArray< MetricsDiffArraymetricsValues_
 CircularArray holding all metric differences, used to compute statistics. More...
 
MetricsStatsIntermediate metricsStatsIntermediate_
 Intermediate statistics arrays. More...
 
MetricsStats metricsStats_
 Final statistics arrays. More...
 

Detailed Description

Class to control the collection of metrics.

Definition at line 42 of file MetricsController.h.

Constructor & Destructor Documentation

◆ MetricsController()

MetroCollect::MetricsController::MetricsController ( MetricsControllerDelegate delegate)
noexcept

Construct a new Metrics Controller object.

Parameters
delegatethe controller's delegate

Definition at line 33 of file MetricsController.cc.

Member Function Documentation

◆ collectMetrics()

void MetroCollect::MetricsController::collectMetrics ( )

Launch metric collection loop.

Definition at line 176 of file MetricsController.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeFinalStats()

void MetroCollect::MetricsController::computeFinalStats ( )
protected

Compute final stats at the end of processing window.

Definition at line 264 of file MetricsController.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convertToUnitsPerSeconds()

bool MetroCollect::MetricsController::convertToUnitsPerSeconds ( ) const
noexcept

Returns whether to convert metric differences to units per second.

Definition at line 84 of file MetricsController.cc.

◆ delegate()

MetricsControllerDelegate & MetroCollect::MetricsController::delegate ( ) const
noexcept

Returns the controller's delegate.

Definition at line 50 of file MetricsController.cc.

◆ isCollecting()

bool MetroCollect::MetricsController::isCollecting ( ) const
noexcept

Returns whether the controller is collecting metrics.

Definition at line 55 of file MetricsController.cc.

◆ isMetricNull()

bool MetroCollect::MetricsController::isMetricNull ( size_t  index) const

Checks wether a metric is zero.

Parameters
indexindex of the metric to check
Returns
true if the metric earlier and latest values are zero
false otherwise

Definition at line 229 of file MetricsController.cc.

◆ processingWindowLength()

size_t MetroCollect::MetricsController::processingWindowLength ( ) const
noexcept

Returns the length of the processing window used to compute statistics.

Definition at line 76 of file MetricsController.cc.

◆ processingWindowOverlap()

size_t MetroCollect::MetricsController::processingWindowOverlap ( ) const
noexcept

Returns the overlap of the processing window used to compute statistics.

Definition at line 80 of file MetricsController.cc.

◆ requestedMetrics()

const std::vector< size_t > & MetroCollect::MetricsController::requestedMetrics ( ) const
noexcept

Returns the list of request metrics.

Definition at line 68 of file MetricsController.cc.

Here is the caller graph for this function:

◆ resetIterativeStats()

void MetroCollect::MetricsController::resetIterativeStats ( )
protected

Reset iterative stats to begin new processing window.

Definition at line 288 of file MetricsController.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ samplingInterval()

std::chrono::milliseconds MetroCollect::MetricsController::samplingInterval ( ) const
noexcept

Returns the metrics sampling interval.

Definition at line 72 of file MetricsController.cc.

◆ sendStats()

bool MetroCollect::MetricsController::sendStats ( ) const
noexcept

Returns whether the controller alerts the delegate after computing statistics.

Definition at line 64 of file MetricsController.cc.

Here is the caller graph for this function:

◆ sendValues()

bool MetroCollect::MetricsController::sendValues ( ) const
noexcept

Returns whether the controller alerts the delegate after collecting new values.

Definition at line 60 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setConvertToUnitsPerSeconds()

void MetroCollect::MetricsController::setConvertToUnitsPerSeconds ( bool  convertToUnitsPerSecond)
noexcept

Sets whether to convert metric differences to units per second.

Definition at line 168 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setProcessingWindow()

void MetroCollect::MetricsController::setProcessingWindow ( size_t  length,
size_t  overlap 
)
noexcept

Sets the processing window parameters used to compute statistics.

Parameters
lengthlength of the processing window
overlapoverlap of the processing window

Definition at line 153 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setRequestedMetrics()

void MetroCollect::MetricsController::setRequestedMetrics ( const MetricsArray< Statistics::Stats > &  requestedMetrics)
noexcept

Sets the list of request metrics.

Definition at line 97 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setSamplingInterval()

void MetroCollect::MetricsController::setSamplingInterval ( std::chrono::milliseconds  interval)
noexcept

Sets the metrics sampling interval.

Definition at line 142 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setSendStats()

void MetroCollect::MetricsController::setSendStats ( bool  sendStats)
noexcept

Sets whether the controller alerts the delegate after computing statistics.

Definition at line 93 of file MetricsController.cc.

Here is the caller graph for this function:

◆ setSendValues()

void MetroCollect::MetricsController::setSendValues ( bool  sendValues)
noexcept

Sets whether the controller alerts the delegate after collecting new values.

Definition at line 89 of file MetricsController.cc.

Here is the caller graph for this function:

◆ updateIterativeStats()

void MetroCollect::MetricsController::updateIterativeStats ( )
protected

Update iterative stats with new MetricsDiffArray.

Definition at line 241 of file MetricsController.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateMetrics()

void MetroCollect::MetricsController::updateMetrics ( )
protected

Fetch latest metrics from source and compute their variations.

Definition at line 234 of file MetricsController.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ convertToUnitsPerSecond_

bool MetroCollect::MetricsController::convertToUnitsPerSecond_
protected

Whether to convert metric differences to units per second.

Definition at line 141 of file MetricsController.h.

◆ currentMetrics_

std::unique_ptr<MetricsDataArray> MetroCollect::MetricsController::currentMetrics_
protected

Pointer to latest metric raw values.

Definition at line 146 of file MetricsController.h.

◆ defaultConvertToUnitsPerSecond

constexpr bool MetroCollect::MetricsController::defaultConvertToUnitsPerSecond = true
static

Default parameter option.

Definition at line 53 of file MetricsController.h.

◆ defaultProcessingWindowLength

constexpr size_t MetroCollect::MetricsController::defaultProcessingWindowLength = 10
static

Default parameter option.

Definition at line 51 of file MetricsController.h.

◆ defaultProcessingWindowOverlap

constexpr size_t MetroCollect::MetricsController::defaultProcessingWindowOverlap = 0
static

Default parameter option.

Definition at line 52 of file MetricsController.h.

◆ defaultSamplingInterval

constexpr std::chrono::milliseconds MetroCollect::MetricsController::defaultSamplingInterval = 100ms
static

Default parameter option.

Definition at line 49 of file MetricsController.h.

◆ defaultSendStats

constexpr bool MetroCollect::MetricsController::defaultSendStats = false
static

Default parameter option.

Definition at line 45 of file MetricsController.h.

◆ defaultSendValues

constexpr bool MetroCollect::MetricsController::defaultSendValues = false
static

Default parameter option.

Definition at line 44 of file MetricsController.h.

◆ delegate_

MetricsControllerDelegate& MetroCollect::MetricsController::delegate_
protected

Delegate to alert when something happens.

Definition at line 132 of file MetricsController.h.

◆ isCollecting_

bool MetroCollect::MetricsController::isCollecting_
protected

Whether the receiver is collecting metrics.

Definition at line 138 of file MetricsController.h.

◆ metricsStats_

MetricsStats MetroCollect::MetricsController::metricsStats_
protected

Final statistics arrays.

Definition at line 151 of file MetricsController.h.

◆ metricsStatsIntermediate_

MetricsStatsIntermediate MetroCollect::MetricsController::metricsStatsIntermediate_
protected

Intermediate statistics arrays.

Definition at line 150 of file MetricsController.h.

◆ metricsValues_

CircularArray::CircularArray<MetricsDiffArray> MetroCollect::MetricsController::metricsValues_
protected

CircularArray holding all metric differences, used to compute statistics.

Definition at line 149 of file MetricsController.h.

◆ previousMetrics_

std::unique_ptr<MetricsDataArray> MetroCollect::MetricsController::previousMetrics_
protected

Pointer to earlier metric raw values.

Definition at line 147 of file MetricsController.h.

◆ processingWindowLength_

size_t MetroCollect::MetricsController::processingWindowLength_
protected

Length of processing window used to compute statistics.

Definition at line 143 of file MetricsController.h.

◆ processingWindowOverlap_

size_t MetroCollect::MetricsController::processingWindowOverlap_
protected

Overlap of processing window used to compute statistics.

Definition at line 144 of file MetricsController.h.

◆ requestedMetrics_

std::vector<size_t> MetroCollect::MetricsController::requestedMetrics_
protected

Indexes of metrics requested to be collected.

Definition at line 134 of file MetricsController.h.

◆ samplingInterval_

std::chrono::milliseconds MetroCollect::MetricsController::samplingInterval_
protected

Metrics sampling interval.

Definition at line 139 of file MetricsController.h.

◆ sendStats_

bool MetroCollect::MetricsController::sendStats_
protected

Whether to compute stats and give them to the delegate.

Definition at line 136 of file MetricsController.h.

◆ sendValues_

bool MetroCollect::MetricsController::sendValues_
protected

Whether to give values to the delegate.

Definition at line 135 of file MetricsController.h.

◆ sourceInterests_

MetricsSource::SourceInterests MetroCollect::MetricsController::sourceInterests_
protected

Boolean arrays to store source interests.

Definition at line 133 of file MetricsController.h.

◆ unitsPerSecondFactor_

double MetroCollect::MetricsController::unitsPerSecondFactor_
protected

Factor to convert metric differences to units per second.

Definition at line 140 of file MetricsController.h.


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