Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
MetricExportersTest Class Reference
Inheritance diagram for MetricExportersTest:
Inheritance graph
Collaboration diagram for MetricExportersTest:
Collaboration graph

Protected Member Functions

void SetUp () override
 
monitoring_data create_test_monitoring_data ()
 
metrics_snapshot create_test_snapshot ()
 

Protected Attributes

monitoring_data test_data_
 
metrics_snapshot test_snapshot_
 
otel_resource otel_resource_
 

Detailed Description

Definition at line 19 of file test_metric_exporters.cpp.

Member Function Documentation

◆ create_test_monitoring_data()

monitoring_data MetricExportersTest::create_test_monitoring_data ( )
inlineprotected

Definition at line 32 of file test_metric_exporters.cpp.

32 {
33 monitoring_data data("web_server");
34 data.add_metric("http_requests_total", 1500.0);
35 data.add_metric("http_request_duration_seconds", 0.250);
36 data.add_metric("memory_usage_bytes", 1024000.0);
37 data.add_metric("cpu_usage_percent", 75.5);
38
39 data.add_tag("environment", "production");
40 data.add_tag("region", "us-west-2");
41 data.add_tag("version", "1.2.3");
42
43 return data;
44 }
Container for monitoring metrics from a component.

References kcenon::monitoring::monitoring_data::add_metric(), and kcenon::monitoring::monitoring_data::add_tag().

Referenced by SetUp().

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

◆ create_test_snapshot()

metrics_snapshot MetricExportersTest::create_test_snapshot ( )
inlineprotected

Definition at line 46 of file test_metric_exporters.cpp.

46 {
47 metrics_snapshot snapshot;
48 snapshot.source_id = "system_monitor";
49 snapshot.capture_time = std::chrono::system_clock::now();
50
51 snapshot.add_metric("system_load_1m", 2.1);
52 snapshot.add_metric("system_load_5m", 1.8);
53 snapshot.add_metric("disk_usage_percent", 68.3);
54 snapshot.add_metric("network_bytes_in", 987654.0);
55 snapshot.add_metric("network_bytes_out", 654321.0);
56
57 // Add tags to metrics
58 snapshot.metrics[0].tags["host"] = "server01";
59 snapshot.metrics[1].tags["host"] = "server01";
60 snapshot.metrics[2].tags["mount"] = "/var";
61 snapshot.metrics[3].tags["interface"] = "eth0";
62 snapshot.metrics[4].tags["interface"] = "eth0";
63
64 return snapshot;
65 }
Complete snapshot of metrics at a point in time.
std::chrono::system_clock::time_point capture_time
std::vector< metric_value > metrics
void add_metric(const std::string &name, double value)
Add a metric to the snapshot.

References kcenon::monitoring::metrics_snapshot::add_metric(), kcenon::monitoring::metrics_snapshot::capture_time, kcenon::monitoring::metrics_snapshot::metrics, and kcenon::monitoring::metrics_snapshot::source_id.

Referenced by SetUp().

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

◆ SetUp()

void MetricExportersTest::SetUp ( )
inlineoverrideprotected

Definition at line 21 of file test_metric_exporters.cpp.

21 {
22 // Create test monitoring data
24
25 // Create test metrics snapshot
27
28 // Create OTEL resource
29 otel_resource_ = create_service_resource("test_service", "1.0.0", "test_namespace");
30 }
metrics_snapshot create_test_snapshot()
metrics_snapshot test_snapshot_
monitoring_data create_test_monitoring_data()
otel_resource create_service_resource(const std::string &service_name, const std::string &service_version="1.0.0", const std::string &service_namespace="")
Create OpenTelemetry resource with service information.

References kcenon::monitoring::create_service_resource(), create_test_monitoring_data(), create_test_snapshot(), otel_resource_, test_data_, and test_snapshot_.

Here is the call graph for this function:

Member Data Documentation

◆ otel_resource_

otel_resource MetricExportersTest::otel_resource_
protected

Definition at line 69 of file test_metric_exporters.cpp.

Referenced by SetUp().

◆ test_data_

monitoring_data MetricExportersTest::test_data_
protected

Definition at line 67 of file test_metric_exporters.cpp.

Referenced by SetUp().

◆ test_snapshot_

metrics_snapshot MetricExportersTest::test_snapshot_
protected

Definition at line 68 of file test_metric_exporters.cpp.

Referenced by SetUp().


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