Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::histogram_data Struct Reference

Histogram data with buckets. More...

#include <metric_types.h>

Collaboration diagram for kcenon::monitoring::histogram_data:
Collaboration graph

Public Member Functions

void add_sample (double value)
 Add value to histogram.
 
double mean () const noexcept
 Get mean value.
 
void init_standard_buckets ()
 Initialize standard buckets.
 

Public Attributes

std::vector< histogram_bucketbuckets
 
uint64_t total_count = 0
 
double sum = 0.0
 

Detailed Description

Histogram data with buckets.

Examples
custom_metric_types_example.cpp.

Definition at line 275 of file metric_types.h.

Member Function Documentation

◆ add_sample()

void kcenon::monitoring::histogram_data::add_sample ( double value)
inline

Add value to histogram.

Examples
custom_metric_types_example.cpp.

Definition at line 283 of file metric_types.h.

283 {
284 sum += value;
285 total_count++;
286
287 for (auto& bucket : buckets) {
288 if (value <= bucket.upper_bound) {
289 bucket.count++;
290 }
291 }
292 }
std::vector< histogram_bucket > buckets

References buckets, sum, and total_count.

Referenced by demonstrate_histogram(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

◆ init_standard_buckets()

void kcenon::monitoring::histogram_data::init_standard_buckets ( )
inline

Initialize standard buckets.

Definition at line 304 of file metric_types.h.

304 {
305 buckets = {
306 {0.005, 0}, {0.01, 0}, {0.025, 0}, {0.05, 0}, {0.075, 0},
307 {0.1, 0}, {0.25, 0}, {0.5, 0}, {0.75, 0}, {1.0, 0},
308 {2.5, 0}, {5.0, 0}, {7.5, 0}, {10.0, 0},
309 {std::numeric_limits<double>::infinity(), 0}
310 };
311 }

References buckets.

Referenced by TEST_F(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

◆ mean()

double kcenon::monitoring::histogram_data::mean ( ) const
inlinenoexcept

Get mean value.

Examples
custom_metric_types_example.cpp.

Definition at line 297 of file metric_types.h.

297 {
298 return total_count > 0 ? sum / total_count : 0.0;
299 }

References sum, and total_count.

Referenced by demonstrate_histogram(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ buckets

std::vector<histogram_bucket> kcenon::monitoring::histogram_data::buckets

◆ sum

double kcenon::monitoring::histogram_data::sum = 0.0

◆ total_count

uint64_t kcenon::monitoring::histogram_data::total_count = 0

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