MetroCollect  2.3.4
SnapInterface::SnapStreamInterface Class Referencefinal

Interface class between MetricsController and Snap's streaming-collector plugin class. More...

#include <SnapStreamInterface.h>

Inheritance diagram for SnapInterface::SnapStreamInterface:
Collaboration diagram for SnapInterface::SnapStreamInterface:

Classes

struct  MetricsPackage
 Strcut to store Snap metric objects and metric data to make it faster to send them to Snap. More...
 

Public Member Functions

 SnapStreamInterface ()
 Construct a new Snap Stream Interface object. More...
 
const Plugin::ConfigPolicy get_config_policy () override final
 Returns the plugin configuration keys and default values to Snap. More...
 
std::vector< Plugin::Metric > get_metric_types (Plugin::Config cfg) override final
 Returns all metrics that can be fetched by the plugin to Snap. More...
 
void get_metrics_in (std::vector< Plugin::Metric > &metsIn) override final
 Gets the user's requested metrics from Snap. More...
 
void stream_metrics () override final
 Stream metrics to Snap. More...
 
void metricsContollerCollectedMetricsValues (const MetroCollect::MetricsController &metricsController, const MetroCollect::MetricsDiffArray &metricsDiff, const MetroCollect::MetricsDataArray &previousMetrics, const MetroCollect::MetricsDataArray &currentMetrics) override final
 Function called every time the MetricsController has collected new values. More...
 
void metricsContollerCollectedMetricsStats (const MetroCollect::MetricsController &metricsController, const MetroCollect::MetricsController::MetricsStats &metricsStats) override final
 Function called every time the MetricsController has computed statistics. More...
 
bool metricsContollerShouldStopCollectingMetrics (const MetroCollect::MetricsController &metricsController) override final
 Function called after each iteration to ask the delegate whether the controller should stop collecting metrics. More...
 

Static Public Attributes

static constexpr int appVersion = 2
 Snap plugin version. More...
 
static constexpr std::string_view appName = "metrocollect"sv
 Snap plugin name. More...
 

Protected Member Functions

void setConfig (const Plugin::Config &cfg)
 Configures the plugin and the controller accordingly, unspecified values are reset to default. More...
 
void parseSnapMetrics (const std::vector< Plugin::Metric > &metrics)
 Generate requestedMetrics array from list of Snap metrics. More...
 
void insertAppPrefixToNamespace (std::vector< std::string > &ns)
 Inserts plugin name prefix into Snap namespace. More...
 
void createRequestedMetrics (MetricsPackage &package, std::string suffix, std::function< bool(MetroCollect::Statistics::Stats, bool *)> condition)
 Configures a MetricsPackage object according to requested metrics. More...
 
void fillMetricsPackage (MetricsPackage &package)
 Initializes a MetricsPackage sub-sampling counters. More...
 
void sendMetrics (MetricsPackage &package, std::function< void(MetricsPackage::TimedMetrics &)> copyMetrics)
 Filters and sends metrics form a package to Snap. More...
 

Protected Attributes

MetroCollect::MetricsController metricsController_
 MetricsController used to collect statistics. More...
 
MetroCollect::MetricsArray< MetroCollect::Statistics::StatsrequestedMetrics_
 Array of requested metrics. More...
 
size_t unchangedMetricsTimeout_
 Sub-sampling period for constant metrics. More...
 
MetricsPackage valuesPackage_
 MetricsPackage for metrics from raw counters variations. More...
 
MetricsPackage statsPackage_
 MetricsPackage for metrics from computed statistics. More...
 

Static Protected Attributes

static constexpr std::array appPrefix = {"cfm"sv}
 Snap metric name prefix. More...
 
static constexpr std::string_view configKeySendValues = "SendValues"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeySendStats = "SendStats"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeySamplingInterval = "SamplingInterval"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyProcessingWindowLength = "ProcessingWindowLength"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyProcessingWindowOverlap = "ProcessingWindowOverlap"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyConvertToUnitsPerSecond = "ConvertToUnitsPerSecond"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyUnchangedMetricTimeout = "UnchangedMetricTimeout"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyMaxCollectDuration = "MaxCollectDuration"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyMaxMetricsBuffer = "MaxMetricsBuffer"sv
 Snap plugin configuration key. More...
 
static constexpr std::array configKeysInt = {configKeySamplingInterval, configKeyProcessingWindowLength, configKeyProcessingWindowOverlap, configKeyUnchangedMetricTimeout, configKeyMaxCollectDuration, configKeyMaxMetricsBuffer}
 Array of integer-valued configuration keys. More...
 
static constexpr std::array configKeysBool = {configKeySendValues, configKeySendStats, configKeyConvertToUnitsPerSecond}
 Array of boolean-valued configuration keys. More...
 
static constexpr bool defaultSendValues = false
 Snap plugin configuration default value. More...
 
static constexpr bool defaultSendStats = true
 Snap plugin configuration default value. More...
 
static constexpr size_t defaultUnchangedMetricTimeout = 300
 Snap plugin configuration default value. More...
 
static constexpr std::chrono::seconds defaultMaxCollectDuration = 0s
 Snap plugin configuration default value. More...
 
static constexpr size_t defaultMaxMetricsBuffer = 0
 Snap plugin configuration default value. More...
 
static constexpr std::array< int, configKeysInt.size()> configValuesInt = {MetroCollect::MetricsController::defaultSamplingInterval.count(), MetroCollect::MetricsController::defaultProcessingWindowLength, MetroCollect::MetricsController::defaultProcessingWindowOverlap, SnapStreamInterface::defaultUnchangedMetricTimeout, SnapStreamInterface::defaultMaxCollectDuration.count(), SnapStreamInterface::defaultMaxMetricsBuffer}
 Array of integer-valued configuration default values. More...
 
static constexpr std::array< bool, configKeysBool.size()> configValuesBool = {defaultSendValues, defaultSendStats, MetroCollect::MetricsController::defaultConvertToUnitsPerSecond}
 Array of boolean-valued configuration default values. More...
 
static constexpr std::string_view statNamespaceLastComponent = "value"sv
 Snap metric name category. More...
 
static constexpr std::string_view statNamespaceDescription = "statistic"sv
 Snap metric name description. More...
 

Detailed Description

Interface class between MetricsController and Snap's streaming-collector plugin class.

Definition at line 41 of file SnapStreamInterface.h.

Constructor & Destructor Documentation

◆ SnapStreamInterface()

SnapInterface::SnapStreamInterface::SnapStreamInterface ( )

Construct a new Snap Stream Interface object.

Definition at line 29 of file SnapStreamInterface.cc.

Member Function Documentation

◆ createRequestedMetrics()

void SnapInterface::SnapStreamInterface::createRequestedMetrics ( MetricsPackage package,
std::string  suffix,
std::function< bool(MetroCollect::Statistics::Stats, bool *)>  condition 
)
protected

Configures a MetricsPackage object according to requested metrics.

Parameters
packagepackage to configure
suffixsuffix to add to all package's metrics names (generally a statistic name)
conditionboolean function specifying whether a requested metric should be included, and whether it is a primary metric

Definition at line 95 of file SnapStreamInterface.cc.

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

◆ fillMetricsPackage()

void SnapInterface::SnapStreamInterface::fillMetricsPackage ( MetricsPackage package)
protected

Initializes a MetricsPackage sub-sampling counters.

Parameters
package

Definition at line 118 of file SnapStreamInterface.cc.

Here is the caller graph for this function:

◆ get_config_policy()

const Plugin::ConfigPolicy SnapInterface::SnapStreamInterface::get_config_policy ( )
finaloverride

Returns the plugin configuration keys and default values to Snap.

Returns
The plugin default configuration

Definition at line 172 of file SnapStreamInterface.cc.

Here is the call graph for this function:

◆ get_metric_types()

std::vector< Plugin::Metric > SnapInterface::SnapStreamInterface::get_metric_types ( Plugin::Config  cfg)
finaloverride

Returns all metrics that can be fetched by the plugin to Snap.

Parameters
cfgincomming Snap configuration values
Returns
metrics that can be fetched

Definition at line 190 of file SnapStreamInterface.cc.

Here is the call graph for this function:

◆ get_metrics_in()

void SnapInterface::SnapStreamInterface::get_metrics_in ( std::vector< Plugin::Metric > &  metsIn)
finaloverride

Gets the user's requested metrics from Snap.

Parameters
metsInthe user's requested metrics array

Definition at line 215 of file SnapStreamInterface.cc.

Here is the call graph for this function:

◆ insertAppPrefixToNamespace()

void SnapInterface::SnapStreamInterface::insertAppPrefixToNamespace ( std::vector< std::string > &  ns)
protected

Inserts plugin name prefix into Snap namespace.

Parameters
nsSnap namespace to modify

Definition at line 91 of file SnapStreamInterface.cc.

Here is the caller graph for this function:

◆ metricsContollerCollectedMetricsStats()

void SnapInterface::SnapStreamInterface::metricsContollerCollectedMetricsStats ( const MetroCollect::MetricsController metricsController,
const MetroCollect::MetricsController::MetricsStats metricsStats 
)
finaloverridevirtual

Function called every time the MetricsController has computed statistics.

Parameters
metricsControllerthe calling MetricsController
metricsStatscomputed statistics

Implements MetroCollect::MetricsControllerDelegate.

Definition at line 256 of file SnapStreamInterface.cc.

Here is the call graph for this function:

◆ metricsContollerCollectedMetricsValues()

void SnapInterface::SnapStreamInterface::metricsContollerCollectedMetricsValues ( const MetroCollect::MetricsController metricsController,
const MetroCollect::MetricsDiffArray metricsDiff,
const MetroCollect::MetricsDataArray previousMetrics,
const MetroCollect::MetricsDataArray currentMetrics 
)
finaloverridevirtual

Function called every time the MetricsController has collected new values.

Parameters
metricsControllerthe calling MetricsController
metricsDiffcomputed metrics differences
previousMetricsearlier collected metrics
currentMetricslatest collected metrics

Implements MetroCollect::MetricsControllerDelegate.

Definition at line 245 of file SnapStreamInterface.cc.

Here is the call graph for this function:

◆ metricsContollerShouldStopCollectingMetrics()

bool SnapInterface::SnapStreamInterface::metricsContollerShouldStopCollectingMetrics ( const MetroCollect::MetricsController metricsController)
finaloverridevirtual

Function called after each iteration to ask the delegate whether the controller should stop collecting metrics.

Parameters
metricsControllerthe calling MetricsController
Returns
true if the controller should stop
false otherwise

Implements MetroCollect::MetricsControllerDelegate.

Definition at line 269 of file SnapStreamInterface.cc.

◆ parseSnapMetrics()

void SnapInterface::SnapStreamInterface::parseSnapMetrics ( const std::vector< Plugin::Metric > &  metrics)
protected

Generate requestedMetrics array from list of Snap metrics.

Parameters
metricsSnap metrics requested by the user

Definition at line 69 of file SnapStreamInterface.cc.

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

◆ sendMetrics()

void SnapInterface::SnapStreamInterface::sendMetrics ( MetricsPackage package,
std::function< void(MetricsPackage::TimedMetrics &)>  copyMetrics 
)
protected

Filters and sends metrics form a package to Snap.

Parameters
packagemetrics to send
copyMetricsfunction used to copy new metrics into the package

Definition at line 127 of file SnapStreamInterface.cc.

Here is the caller graph for this function:

◆ setConfig()

void SnapInterface::SnapStreamInterface::setConfig ( const Plugin::Config &  cfg)
protected

Configures the plugin and the controller accordingly, unspecified values are reset to default.

Parameters
cfgconfiguration options to use

Definition at line 34 of file SnapStreamInterface.cc.

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

◆ stream_metrics()

void SnapInterface::SnapStreamInterface::stream_metrics ( )
finaloverride

Stream metrics to Snap.

Definition at line 208 of file SnapStreamInterface.cc.

Here is the call graph for this function:

Member Data Documentation

◆ appName

constexpr std::string_view SnapInterface::SnapStreamInterface::appName = "metrocollect"sv
static

Snap plugin name.

Definition at line 44 of file SnapStreamInterface.h.

◆ appPrefix

constexpr std::array SnapInterface::SnapStreamInterface::appPrefix = {"cfm"sv}
staticprotected

Snap metric name prefix.

Definition at line 84 of file SnapStreamInterface.h.

◆ appVersion

constexpr int SnapInterface::SnapStreamInterface::appVersion = 2
static

Snap plugin version.

Definition at line 43 of file SnapStreamInterface.h.

◆ configKeyConvertToUnitsPerSecond

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyConvertToUnitsPerSecond = "ConvertToUnitsPerSecond"sv
staticprotected

Snap plugin configuration key.

Definition at line 90 of file SnapStreamInterface.h.

◆ configKeyMaxCollectDuration

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyMaxCollectDuration = "MaxCollectDuration"sv
staticprotected

Snap plugin configuration key.

Definition at line 92 of file SnapStreamInterface.h.

◆ configKeyMaxMetricsBuffer

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyMaxMetricsBuffer = "MaxMetricsBuffer"sv
staticprotected

Snap plugin configuration key.

Definition at line 93 of file SnapStreamInterface.h.

◆ configKeyProcessingWindowLength

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyProcessingWindowLength = "ProcessingWindowLength"sv
staticprotected

Snap plugin configuration key.

Definition at line 88 of file SnapStreamInterface.h.

◆ configKeyProcessingWindowOverlap

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyProcessingWindowOverlap = "ProcessingWindowOverlap"sv
staticprotected

Snap plugin configuration key.

Definition at line 89 of file SnapStreamInterface.h.

◆ configKeySamplingInterval

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeySamplingInterval = "SamplingInterval"sv
staticprotected

Snap plugin configuration key.

Definition at line 87 of file SnapStreamInterface.h.

◆ configKeysBool

constexpr std::array SnapInterface::SnapStreamInterface::configKeysBool = {configKeySendValues, configKeySendStats, configKeyConvertToUnitsPerSecond}
staticprotected

Array of boolean-valued configuration keys.

Definition at line 95 of file SnapStreamInterface.h.

◆ configKeySendStats

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeySendStats = "SendStats"sv
staticprotected

Snap plugin configuration key.

Definition at line 86 of file SnapStreamInterface.h.

◆ configKeySendValues

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeySendValues = "SendValues"sv
staticprotected

Snap plugin configuration key.

Definition at line 85 of file SnapStreamInterface.h.

◆ configKeysInt

Array of integer-valued configuration keys.

Definition at line 94 of file SnapStreamInterface.h.

◆ configKeyUnchangedMetricTimeout

constexpr std::string_view SnapInterface::SnapStreamInterface::configKeyUnchangedMetricTimeout = "UnchangedMetricTimeout"sv
staticprotected

Snap plugin configuration key.

Definition at line 91 of file SnapStreamInterface.h.

◆ configValuesBool

constexpr std::array<bool, configKeysBool.size()> SnapInterface::SnapStreamInterface::configValuesBool = {defaultSendValues, defaultSendStats, MetroCollect::MetricsController::defaultConvertToUnitsPerSecond}
staticprotected

Array of boolean-valued configuration default values.

Definition at line 102 of file SnapStreamInterface.h.

◆ configValuesInt

constexpr std::array<int, configKeysInt.size()> SnapInterface::SnapStreamInterface::configValuesInt = {MetroCollect::MetricsController::defaultSamplingInterval.count(), MetroCollect::MetricsController::defaultProcessingWindowLength, MetroCollect::MetricsController::defaultProcessingWindowOverlap, SnapStreamInterface::defaultUnchangedMetricTimeout, SnapStreamInterface::defaultMaxCollectDuration.count(), SnapStreamInterface::defaultMaxMetricsBuffer}
staticprotected

Array of integer-valued configuration default values.

Definition at line 101 of file SnapStreamInterface.h.

◆ defaultMaxCollectDuration

constexpr std::chrono::seconds SnapInterface::SnapStreamInterface::defaultMaxCollectDuration = 0s
staticprotected

Snap plugin configuration default value.

Definition at line 99 of file SnapStreamInterface.h.

◆ defaultMaxMetricsBuffer

constexpr size_t SnapInterface::SnapStreamInterface::defaultMaxMetricsBuffer = 0
staticprotected

Snap plugin configuration default value.

Definition at line 100 of file SnapStreamInterface.h.

◆ defaultSendStats

constexpr bool SnapInterface::SnapStreamInterface::defaultSendStats = true
staticprotected

Snap plugin configuration default value.

Definition at line 97 of file SnapStreamInterface.h.

◆ defaultSendValues

constexpr bool SnapInterface::SnapStreamInterface::defaultSendValues = false
staticprotected

Snap plugin configuration default value.

Definition at line 96 of file SnapStreamInterface.h.

◆ defaultUnchangedMetricTimeout

constexpr size_t SnapInterface::SnapStreamInterface::defaultUnchangedMetricTimeout = 300
staticprotected

Snap plugin configuration default value.

Definition at line 98 of file SnapStreamInterface.h.

◆ metricsController_

MetroCollect::MetricsController SnapInterface::SnapStreamInterface::metricsController_
protected

MetricsController used to collect statistics.

Definition at line 106 of file SnapStreamInterface.h.

◆ requestedMetrics_

MetroCollect::MetricsArray<MetroCollect::Statistics::Stats> SnapInterface::SnapStreamInterface::requestedMetrics_
protected

Array of requested metrics.

Definition at line 108 of file SnapStreamInterface.h.

◆ statNamespaceDescription

constexpr std::string_view SnapInterface::SnapStreamInterface::statNamespaceDescription = "statistic"sv
staticprotected

Snap metric name description.

Definition at line 104 of file SnapStreamInterface.h.

◆ statNamespaceLastComponent

constexpr std::string_view SnapInterface::SnapStreamInterface::statNamespaceLastComponent = "value"sv
staticprotected

Snap metric name category.

Definition at line 103 of file SnapStreamInterface.h.

◆ statsPackage_

MetricsPackage SnapInterface::SnapStreamInterface::statsPackage_
protected

MetricsPackage for metrics from computed statistics.

Definition at line 112 of file SnapStreamInterface.h.

◆ unchangedMetricsTimeout_

size_t SnapInterface::SnapStreamInterface::unchangedMetricsTimeout_
protected

Sub-sampling period for constant metrics.

Definition at line 109 of file SnapStreamInterface.h.

◆ valuesPackage_

MetricsPackage SnapInterface::SnapStreamInterface::valuesPackage_
protected

MetricsPackage for metrics from raw counters variations.

Definition at line 111 of file SnapStreamInterface.h.


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