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

Batch of metrics for efficient processing. More...

#include <metric_types.h>

Collaboration diagram for kcenon::monitoring::metric_batch:
Collaboration graph

Public Member Functions

 metric_batch ()
 
 metric_batch (size_t id)
 
void add_metric (compact_metric_value &&metric)
 Add metric to batch.
 
size_t memory_footprint () const noexcept
 Get batch size in bytes.
 
void reserve (size_t count)
 Reserve space for metrics.
 
void clear ()
 Clear all metrics.
 
bool empty () const noexcept
 Check if batch is empty.
 
size_t size () const noexcept
 Get number of metrics in batch.
 

Public Attributes

std::vector< compact_metric_valuemetrics
 
std::chrono::system_clock::time_point batch_timestamp
 
size_t batch_id
 

Detailed Description

Batch of metrics for efficient processing.

Examples
custom_metric_types_example.cpp.

Definition at line 197 of file metric_types.h.

Constructor & Destructor Documentation

◆ metric_batch() [1/2]

kcenon::monitoring::metric_batch::metric_batch ( )
inline

Definition at line 202 of file metric_types.h.

202: batch_timestamp(std::chrono::system_clock::now()), batch_id(0) {}
std::chrono::system_clock::time_point batch_timestamp

Referenced by memory_footprint().

Here is the caller graph for this function:

◆ metric_batch() [2/2]

kcenon::monitoring::metric_batch::metric_batch ( size_t id)
inlineexplicit

Definition at line 204 of file metric_types.h.

205 : batch_timestamp(std::chrono::system_clock::now()), batch_id(id) {}

Member Function Documentation

◆ add_metric()

void kcenon::monitoring::metric_batch::add_metric ( compact_metric_value && metric)
inline

Add metric to batch.

Definition at line 210 of file metric_types.h.

210 {
211 metrics.emplace_back(std::move(metric));
212 }
std::vector< compact_metric_value > metrics

References metrics.

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

Here is the caller graph for this function:

◆ clear()

void kcenon::monitoring::metric_batch::clear ( )
inline

Clear all metrics.

Definition at line 235 of file metric_types.h.

235 {
236 metrics.clear();
237 batch_timestamp = std::chrono::system_clock::now();
238 }

References batch_timestamp, and metrics.

Referenced by demonstrate_metric_batch(), and TEST_F().

Here is the caller graph for this function:

◆ empty()

bool kcenon::monitoring::metric_batch::empty ( ) const
inlinenoexcept

Check if batch is empty.

Definition at line 243 of file metric_types.h.

243 {
244 return metrics.empty();
245 }

References metrics.

Referenced by demonstrate_metric_batch(), and TEST_F().

Here is the caller graph for this function:

◆ memory_footprint()

size_t kcenon::monitoring::metric_batch::memory_footprint ( ) const
inlinenoexcept

Get batch size in bytes.

Definition at line 217 of file metric_types.h.

217 {
218 size_t total = sizeof(metric_batch);
219 for (const auto& metric : metrics) {
220 total += metric.memory_footprint();
221 }
222 return total;
223 }

References metric_batch(), and metrics.

Referenced by demonstrate_metric_batch(), and TEST_F().

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

◆ reserve()

void kcenon::monitoring::metric_batch::reserve ( size_t count)
inline

Reserve space for metrics.

Definition at line 228 of file metric_types.h.

228 {
229 metrics.reserve(count);
230 }

References metrics.

Referenced by demonstrate_metric_batch().

Here is the caller graph for this function:

◆ size()

size_t kcenon::monitoring::metric_batch::size ( ) const
inlinenoexcept

Get number of metrics in batch.

Definition at line 250 of file metric_types.h.

250 {
251 return metrics.size();
252 }

References metrics.

Referenced by demonstrate_metric_batch(), and TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ batch_id

size_t kcenon::monitoring::metric_batch::batch_id

Definition at line 200 of file metric_types.h.

Referenced by demonstrate_metric_batch().

◆ batch_timestamp

std::chrono::system_clock::time_point kcenon::monitoring::metric_batch::batch_timestamp

Definition at line 199 of file metric_types.h.

Referenced by clear().

◆ metrics

std::vector<compact_metric_value> kcenon::monitoring::metric_batch::metrics

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