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

Protected Member Functions

void SetUp () override
 
void TearDown () override
 
std::vector< metrics_snapshotcreate_test_snapshots ()
 

Protected Attributes

std::vector< metrics_snapshottest_snapshots_
 
std::filesystem::path test_dir_
 

Detailed Description

Definition at line 16 of file test_storage_backends.cpp.

Member Function Documentation

◆ create_test_snapshots()

std::vector< metrics_snapshot > StorageBackendsTest::create_test_snapshots ( )
inlineprotected

Definition at line 34 of file test_storage_backends.cpp.

34 {
35 std::vector<metrics_snapshot> snapshots;
36
37 // Create first snapshot
38 metrics_snapshot snap1;
39 snap1.source_id = "web_server";
40 snap1.capture_time = std::chrono::system_clock::now();
41 snap1.add_metric("requests_per_second", 150.0);
42 snap1.add_metric("response_time_ms", 45.2);
43 snap1.add_metric("error_rate", 0.02);
44 snapshots.push_back(snap1);
45
46 // Create second snapshot
47 metrics_snapshot snap2;
48 snap2.source_id = "database";
49 snap2.capture_time = std::chrono::system_clock::now();
50 snap2.add_metric("connections", 25.0);
51 snap2.add_metric("query_time_ms", 12.8);
52 snap2.add_metric("cache_hit_rate", 0.95);
53 snapshots.push_back(snap2);
54
55 // Create third snapshot
56 metrics_snapshot snap3;
57 snap3.source_id = "cache_server";
58 snap3.capture_time = std::chrono::system_clock::now();
59 snap3.add_metric("memory_usage_mb", 512.0);
60 snap3.add_metric("hit_rate", 0.88);
61 snap3.add_metric("evictions_per_sec", 2.1);
62 snapshots.push_back(snap3);
63
64 return snapshots;
65 }
Complete snapshot of metrics at a point in time.
std::chrono::system_clock::time_point capture_time
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, 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 StorageBackendsTest::SetUp ( )
inlineoverrideprotected

Definition at line 18 of file test_storage_backends.cpp.

18 {
19 // Create test snapshots
21
22 // Create test directories
23 test_dir_ = std::filesystem::temp_directory_path() / "monitoring_test";
24 std::filesystem::create_directories(test_dir_);
25 }
std::vector< metrics_snapshot > create_test_snapshots()
std::vector< metrics_snapshot > test_snapshots_
std::filesystem::path test_dir_

References create_test_snapshots(), test_dir_, and test_snapshots_.

Here is the call graph for this function:

◆ TearDown()

void StorageBackendsTest::TearDown ( )
inlineoverrideprotected

Definition at line 27 of file test_storage_backends.cpp.

27 {
28 // Clean up test files
29 if (std::filesystem::exists(test_dir_)) {
30 std::filesystem::remove_all(test_dir_);
31 }
32 }

References test_dir_.

Member Data Documentation

◆ test_dir_

std::filesystem::path StorageBackendsTest::test_dir_
protected

Definition at line 68 of file test_storage_backends.cpp.

Referenced by SetUp(), and TearDown().

◆ test_snapshots_

std::vector<metrics_snapshot> StorageBackendsTest::test_snapshots_
protected

Definition at line 67 of file test_storage_backends.cpp.

Referenced by SetUp().


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