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

Single data point in time series. More...

#include <time_series.h>

Collaboration diagram for kcenon::monitoring::time_point_data:
Collaboration graph

Public Member Functions

 time_point_data () noexcept
 
 time_point_data (std::chrono::system_clock::time_point ts, double val, uint32_t count=1) noexcept
 
void merge (const time_point_data &other)
 Merge another data point (for aggregation)
 
bool is_valid (std::chrono::system_clock::time_point cutoff) const noexcept
 Check if this point is within retention period.
 

Public Attributes

std::chrono::system_clock::time_point timestamp
 
double value
 
uint32_t sample_count
 

Detailed Description

Single data point in time series.

Definition at line 71 of file time_series.h.

Constructor & Destructor Documentation

◆ time_point_data() [1/2]

kcenon::monitoring::time_point_data::time_point_data ( )
inlinenoexcept

Definition at line 76 of file time_series.h.

◆ time_point_data() [2/2]

kcenon::monitoring::time_point_data::time_point_data ( std::chrono::system_clock::time_point ts,
double val,
uint32_t count = 1 )
inlinenoexcept

Definition at line 78 of file time_series.h.

79 : timestamp(ts), value(val), sample_count(count) {}
std::chrono::system_clock::time_point timestamp
Definition time_series.h:72

Member Function Documentation

◆ is_valid()

bool kcenon::monitoring::time_point_data::is_valid ( std::chrono::system_clock::time_point cutoff) const
inlinenoexcept

Check if this point is within retention period.

Definition at line 102 of file time_series.h.

102 {
103 return timestamp >= cutoff;
104 }

References timestamp.

◆ merge()

void kcenon::monitoring::time_point_data::merge ( const time_point_data & other)
inline

Merge another data point (for aggregation)

Definition at line 84 of file time_series.h.

84 {
85 if (sample_count == 0) {
86 *this = other;
87 } else if (other.sample_count > 0) {
88 double total_weight = sample_count + other.sample_count;
89 value = (value * sample_count + other.value * other.sample_count) / total_weight;
90 sample_count += other.sample_count;
91
92 // Use the later timestamp
93 if (other.timestamp > timestamp) {
94 timestamp = other.timestamp;
95 }
96 }
97 }

References kcenon::monitoring::other, sample_count, timestamp, and value.

Referenced by kcenon::monitoring::time_series::query().

Here is the caller graph for this function:

Member Data Documentation

◆ sample_count

uint32_t kcenon::monitoring::time_point_data::sample_count

Definition at line 74 of file time_series.h.

Referenced by merge().

◆ timestamp

std::chrono::system_clock::time_point kcenon::monitoring::time_point_data::timestamp

◆ value

double kcenon::monitoring::time_point_data::value

Definition at line 73 of file time_series.h.

Referenced by merge().


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