37 class MetricsControllerDelegate;
44 static constexpr
bool defaultSendValues =
false;
45 static constexpr
bool defaultSendStats =
false;
47 static constexpr std::chrono::milliseconds defaultSamplingInterval = 0ms;
49 static constexpr std::chrono::milliseconds defaultSamplingInterval = 100ms;
51 static constexpr
size_t defaultProcessingWindowLength = 10;
52 static constexpr
size_t defaultProcessingWindowOverlap = 0;
53 static constexpr
bool defaultConvertToUnitsPerSecond =
true;
70 template<
typename Function>
72 func(minIndexes, Statistics::StatsIndexMin);
73 func(maxIndexes, Statistics::StatsIndexMax);
74 func(sum, Statistics::StatsIndexIntermediateSum);
75 func(sumSquared, Statistics::StatsIndexIntermediateSumSquared);
84 template<
typename Function>
86 func(minIndexes, Statistics::StatsIndexMin);
87 func(maxIndexes, Statistics::StatsIndexMax);
88 func(sum, Statistics::StatsIndexIntermediateSum);
89 func(sumSquared, Statistics::StatsIndexIntermediateSumSquared);
108 template<
typename Function>
110 func(min, Statistics::StatsMin);
111 func(max, Statistics::StatsMax);
112 func(average, Statistics::StatsAverage);
113 func(stdDev, Statistics::StatsStdDev);
122 template<
typename Function>
124 func(min, Statistics::StatsMin);
125 func(max, Statistics::StatsMax);
126 func(average, Statistics::StatsAverage);
127 func(stdDev, Statistics::StatsStdDev);
153 void updateMetrics();
154 void updateIterativeStats();
155 void computeFinalStats();
156 void resetIterativeStats();
176 bool isCollecting() const noexcept;
181 bool sendValues() const noexcept;
186 bool sendStats() const noexcept;
191 const
std::vector<
size_t>& requestedMetrics() const noexcept;
196 std::chrono::milliseconds samplingInterval() const noexcept;
201 size_t processingWindowLength() const noexcept;
206 size_t processingWindowOverlap() const noexcept;
211 bool convertToUnitsPerSeconds() const noexcept;
217 void setSendValues(
bool sendValues) noexcept;
222 void setSendStats(
bool sendStats) noexcept;
232 void setSamplingInterval(
std::chrono::milliseconds interval) noexcept;
240 void setProcessingWindow(
size_t length,
size_t overlap) noexcept;
245 void setConvertToUnitsPerSeconds(
bool convertToUnitsPerSecond) noexcept;
251 void collectMetrics();
261 bool isMetricNull(
size_t index) const;
297 virtual bool metricsContollerShouldStopCollectingMetrics(
const MetricsController& metricsController) = 0;
MetricsStatsArray< DiffValueType > average
Array of averages.
Struct to store all final metric stats.
std::shared_ptr< std::vector< MetricsSource::Interests > > SourceInterests
Type used to store and share interests of multiple sources.
bool sendStats_
Whether to compute stats and give them to the delegate.
std::unique_ptr< MetricsDataArray > currentMetrics_
Pointer to latest metric raw values.
A circular array container.
Generic class to store and manage metrics.
Class holding various statistics-related types and variables.
std::vector< size_t > requestedMetrics_
Indexes of metrics requested to be collected.
MetricsStats metricsStats_
Final statistics arrays.
bool sendValues_
Whether to give values to the delegate.
size_t processingWindowLength_
Length of processing window used to compute statistics.
MetricsStatsArray< DiffValueType > stdDev
Array of standard deviations.
MetricsControllerDelegate & delegate_
Delegate to alert when something happens.
void forEach(Function func)
Execute a function for each stats array.
MetricsStatsIntermediate metricsStatsIntermediate_
Intermediate statistics arrays.
Class to fetch metrics from the kernel and store them.
double unitsPerSecondFactor_
Factor to convert metric differences to units per second.
std::unique_ptr< MetricsDataArray > previousMetrics_
Pointer to earlier metric raw values.
CircularArray::CircularArray< MetricsDiffArray > metricsValues_
CircularArray holding all metric differences, used to compute statistics.
std::chrono::milliseconds samplingInterval_
Metrics sampling interval.
Abstract delegate of MetricsController.
MetricsStatsArray< DiffValueType > min
Array of minimums.
void forEach(Function func) const
Execute a const function for each stats array.
Class to control the collection of metrics.
Class to compute and store metric values variations.
MetricsStatsArray< DiffValueType > max
Array of maximums.
MetricsSource::SourceInterests sourceInterests_
Boolean arrays to store source interests.
size_t processingWindowOverlap_
Overlap of processing window used to compute statistics.
bool isCollecting_
Whether the receiver is collecting metrics.
bool convertToUnitsPerSecond_
Whether to convert metric differences to units per second.