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

Public Member Functions

 mock_collector (const std::string &name)
 
std::string get_name () const override
 Get collector name.
 
bool is_enabled () const override
 Check if collector is enabled.
 
kcenon::common::VoidResult set_enabled (bool enable) override
 Enable or disable the collector.
 
kcenon::common::VoidResult initialize () override
 Initialize the collector.
 
kcenon::common::VoidResult cleanup () override
 Cleanup collector resources.
 
kcenon::common::Result< metrics_snapshotcollect () override
 Collect metrics.
 
int get_collect_count () const
 
void reset_count ()
 
- Public Member Functions inherited from kcenon::monitoring::metrics_collector
virtual ~metrics_collector ()=default
 

Private Attributes

std::string name_
 
std::atomic< int > collect_count_ {0}
 
bool enabled_ {true}
 

Detailed Description

Definition at line 20 of file test_adaptive_monitoring.cpp.

Constructor & Destructor Documentation

◆ mock_collector()

mock_collector::mock_collector ( const std::string & name)
inlineexplicit

Definition at line 27 of file test_adaptive_monitoring.cpp.

27: name_(name) {}

Member Function Documentation

◆ cleanup()

kcenon::common::VoidResult mock_collector::cleanup ( )
inlineoverridevirtual

Cleanup collector resources.

Returns
Result indicating success or cleanup error

Implements kcenon::monitoring::metrics_collector.

Definition at line 41 of file test_adaptive_monitoring.cpp.

41 {
42 return kcenon::common::ok();
43 }

◆ collect()

kcenon::common::Result< metrics_snapshot > mock_collector::collect ( )
inlineoverridevirtual

Collect metrics.

Returns
Result containing collected metrics or error

Implements kcenon::monitoring::metrics_collector.

Definition at line 45 of file test_adaptive_monitoring.cpp.

45 {
47
48 metrics_snapshot snapshot;
49 snapshot.capture_time = std::chrono::system_clock::now();
50 snapshot.source_id = name_;
51 snapshot.add_metric("test_metric", static_cast<double>(collect_count_.load()));
52
53 return kcenon::common::ok(std::move(snapshot));
54 }
std::atomic< int > collect_count_
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, collect_count_, name_, and kcenon::monitoring::metrics_snapshot::source_id.

Here is the call graph for this function:

◆ get_collect_count()

int mock_collector::get_collect_count ( ) const
inline

Definition at line 56 of file test_adaptive_monitoring.cpp.

56{ return collect_count_; }

References collect_count_.

◆ get_name()

std::string mock_collector::get_name ( ) const
inlineoverridevirtual

Get collector name.

Returns
Collector identifier

Implements kcenon::monitoring::metrics_collector.

Definition at line 29 of file test_adaptive_monitoring.cpp.

29{ return name_; }

References name_.

◆ initialize()

kcenon::common::VoidResult mock_collector::initialize ( )
inlineoverridevirtual

Initialize the collector.

Returns
Result indicating success or initialization error

Implements kcenon::monitoring::metrics_collector.

Definition at line 37 of file test_adaptive_monitoring.cpp.

37 {
38 return kcenon::common::ok();
39 }

◆ is_enabled()

bool mock_collector::is_enabled ( ) const
inlineoverridevirtual

Check if collector is enabled.

Returns
true if collector is active

Implements kcenon::monitoring::metrics_collector.

Definition at line 30 of file test_adaptive_monitoring.cpp.

References enabled_.

◆ reset_count()

void mock_collector::reset_count ( )
inline

Definition at line 57 of file test_adaptive_monitoring.cpp.

57{ collect_count_ = 0; }

References collect_count_.

◆ set_enabled()

kcenon::common::VoidResult mock_collector::set_enabled ( bool enable)
inlineoverridevirtual

Enable or disable the collector.

Parameters
enabletrue to enable, false to disable
Returns
Result indicating success or error

Implements kcenon::monitoring::metrics_collector.

Definition at line 32 of file test_adaptive_monitoring.cpp.

32 {
33 enabled_ = enable;
34 return kcenon::common::ok();
35 }

References enabled_.

Member Data Documentation

◆ collect_count_

std::atomic<int> mock_collector::collect_count_ {0}
private

Definition at line 23 of file test_adaptive_monitoring.cpp.

23{0};

Referenced by collect(), get_collect_count(), and reset_count().

◆ enabled_

bool mock_collector::enabled_ {true}
private

Definition at line 24 of file test_adaptive_monitoring.cpp.

24{true};

Referenced by is_enabled(), and set_enabled().

◆ name_

std::string mock_collector::name_
private

Definition at line 22 of file test_adaptive_monitoring.cpp.

Referenced by collect(), and get_name().


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