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

Public Member Functions

kcenon::common::VoidResult export_spans (const std::vector< trace_span > &spans) override
 Export a batch of spans.
 
kcenon::common::VoidResult flush () override
 Flush any pending spans.
 
kcenon::common::VoidResult shutdown () override
 Shutdown the exporter.
 
std::unordered_map< std::string, std::size_t > get_stats () const override
 Get exporter statistics.
 
- Public Member Functions inherited from kcenon::monitoring::trace_exporter_interface
virtual ~trace_exporter_interface ()=default
 

Public Attributes

std::vector< trace_spanexported_spans
 
std::atomic< std::size_t > export_count {0}
 
std::atomic< std::size_t > flush_count {0}
 
std::atomic< std::size_t > shutdown_count {0}
 
bool should_fail = false
 

Detailed Description

Definition at line 362 of file test_distributed_tracing.cpp.

Member Function Documentation

◆ export_spans()

kcenon::common::VoidResult MockTraceExporter::export_spans ( const std::vector< trace_span > & spans)
inlineoverridevirtual

Export a batch of spans.

Implements kcenon::monitoring::trace_exporter_interface.

Definition at line 370 of file test_distributed_tracing.cpp.

370 {
371 if (should_fail) {
372 return kcenon::common::VoidResult::err(error_info(monitoring_error_code::operation_failed,
373 "Mock export failure", "test").to_common_error());
374 }
375 for (const auto& span : spans) {
376 exported_spans.push_back(span);
377 }
378 export_count++;
379 return kcenon::common::ok();
380 }
std::atomic< std::size_t > export_count
std::vector< trace_span > exported_spans
Extended error information with context.

References export_count, exported_spans, and should_fail.

◆ flush()

kcenon::common::VoidResult MockTraceExporter::flush ( )
inlineoverridevirtual

Flush any pending spans.

Implements kcenon::monitoring::trace_exporter_interface.

Definition at line 382 of file test_distributed_tracing.cpp.

382 {
383 flush_count++;
384 return kcenon::common::ok();
385 }
std::atomic< std::size_t > flush_count

References flush_count.

◆ get_stats()

std::unordered_map< std::string, std::size_t > MockTraceExporter::get_stats ( ) const
inlineoverridevirtual

Get exporter statistics.

Implements kcenon::monitoring::trace_exporter_interface.

Definition at line 392 of file test_distributed_tracing.cpp.

392 {
393 return {
394 {"exported_spans", exported_spans.size()},
395 {"export_count", export_count.load()},
396 {"flush_count", flush_count.load()},
397 {"shutdown_count", shutdown_count.load()}
398 };
399 }
std::atomic< std::size_t > shutdown_count

References export_count, exported_spans, flush_count, and shutdown_count.

◆ shutdown()

kcenon::common::VoidResult MockTraceExporter::shutdown ( )
inlineoverridevirtual

Shutdown the exporter.

Implements kcenon::monitoring::trace_exporter_interface.

Definition at line 387 of file test_distributed_tracing.cpp.

387 {
389 return kcenon::common::ok();
390 }

References shutdown_count.

Member Data Documentation

◆ export_count

std::atomic<std::size_t> MockTraceExporter::export_count {0}

Definition at line 365 of file test_distributed_tracing.cpp.

365{0};

Referenced by export_spans(), and get_stats().

◆ exported_spans

std::vector<trace_span> MockTraceExporter::exported_spans

Definition at line 364 of file test_distributed_tracing.cpp.

Referenced by export_spans(), and get_stats().

◆ flush_count

std::atomic<std::size_t> MockTraceExporter::flush_count {0}

Definition at line 366 of file test_distributed_tracing.cpp.

366{0};

Referenced by flush(), and get_stats().

◆ should_fail

bool MockTraceExporter::should_fail = false

Definition at line 368 of file test_distributed_tracing.cpp.

Referenced by export_spans().

◆ shutdown_count

std::atomic<std::size_t> MockTraceExporter::shutdown_count {0}

Definition at line 367 of file test_distributed_tracing.cpp.

367{0};

Referenced by get_stats(), and shutdown().


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