|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
StatsD metric exporter implementation. More...
#include <metric_exporters.h>


Public Member Functions | |
| statsd_exporter (const metric_export_config &config) | |
| Construct StatsD exporter with default UDP transport. | |
| statsd_exporter (const metric_export_config &config, std::unique_ptr< udp_transport > transport) | |
| Construct StatsD exporter with custom UDP transport. | |
| std::vector< statsd_metric_data > | convert_monitoring_data (const monitoring_data &data) const |
| Convert monitoring_data to StatsD format. | |
| std::vector< statsd_metric_data > | convert_snapshot (const metrics_snapshot &snapshot) const |
| Convert metrics_snapshot to StatsD format. | |
| common::VoidResult | export_metrics (const std::vector< monitoring_data > &metrics) override |
| Export a batch of metrics. | |
| common::VoidResult | export_snapshot (const metrics_snapshot &snapshot) override |
| Export a single metrics snapshot. | |
| common::VoidResult | start () override |
| Start the exporter (for pull-based systems) | |
| common::VoidResult | stop () override |
| Stop the exporter. | |
| common::VoidResult | flush () override |
| Flush any pending metrics. | |
| 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::metric_exporter_interface | |
| virtual | ~metric_exporter_interface ()=default |
Private Member Functions | |
| common::VoidResult | send_udp_batch (const std::vector< std::string > &lines) |
| std::string | sanitize_metric_name (const std::string &name) const |
| metric_type | infer_metric_type (const std::string &name, double) const |
Private Attributes | |
| metric_export_config | config_ |
| std::unique_ptr< udp_transport > | transport_ |
| std::atomic< std::size_t > | exported_metrics_ {0} |
| std::atomic< std::size_t > | failed_exports_ {0} |
| std::atomic< std::size_t > | sent_packets_ {0} |
| bool | started_ {false} |
StatsD metric exporter implementation.
Exports metrics to StatsD-compatible backends via UDP. Supports both plain StatsD and DataDog extension formats.
Definition at line 505 of file metric_exporters.h.
|
inlineexplicit |
Construct StatsD exporter with default UDP transport.
| config | Export configuration with endpoint and port |
Definition at line 519 of file metric_exporters.h.
|
inline |
Construct StatsD exporter with custom UDP transport.
| config | Export configuration |
| transport | Custom UDP transport implementation |
Definition at line 528 of file metric_exporters.h.
|
inline |
Convert monitoring_data to StatsD format.
Definition at line 536 of file metric_exporters.h.
References config_, kcenon::monitoring::monitoring_data::get_component_name(), kcenon::monitoring::monitoring_data::get_metrics(), kcenon::monitoring::monitoring_data::get_tags(), infer_metric_type(), kcenon::monitoring::metric_export_config::instance_id, kcenon::monitoring::metric_export_config::labels, kcenon::monitoring::metric::name, sanitize_metric_name(), kcenon::monitoring::metric::tags, kcenon::monitoring::metric::type, and kcenon::monitoring::metric::value.
Referenced by export_metrics(), TEST_F(), and TEST_F().


|
inline |
Convert metrics_snapshot to StatsD format.
Definition at line 572 of file metric_exporters.h.
References config_, infer_metric_type(), kcenon::monitoring::metric_export_config::instance_id, kcenon::monitoring::metric_export_config::labels, kcenon::monitoring::metrics_snapshot::metrics, kcenon::monitoring::metric::name, sanitize_metric_name(), kcenon::monitoring::metrics_snapshot::source_id, kcenon::monitoring::metric::tags, kcenon::monitoring::metric::type, and kcenon::monitoring::metric::value.
Referenced by export_snapshot(), and TEST_F().


|
inlineoverridevirtual |
Export a batch of metrics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 607 of file metric_exporters.h.
References config_, convert_monitoring_data(), exported_metrics_, failed_exports_, kcenon::monitoring::metric_export_config::format, kcenon::monitoring::operation_failed, send_udp_batch(), sent_packets_, kcenon::monitoring::statsd_datadog, and kcenon::monitoring::error_info::to_common_error().
Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
inlineoverridevirtual |
Export a single metrics snapshot.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 638 of file metric_exporters.h.
References config_, convert_snapshot(), exported_metrics_, failed_exports_, kcenon::monitoring::metric_export_config::format, kcenon::monitoring::operation_failed, send_udp_batch(), sent_packets_, kcenon::monitoring::statsd_datadog, and kcenon::monitoring::error_info::to_common_error().
Referenced by TEST_F().


|
inlineoverridevirtual |
Flush any pending metrics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 703 of file metric_exporters.h.
Referenced by TEST_F().

|
inlineoverridevirtual |
Get exporter statistics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 712 of file metric_exporters.h.
References exported_metrics_, failed_exports_, sent_packets_, and transport_.
Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inlineprivate |
Definition at line 770 of file metric_exporters.h.
References kcenon::monitoring::counter, kcenon::monitoring::gauge, and kcenon::monitoring::timer.
Referenced by convert_monitoring_data(), and convert_snapshot().

|
inlineprivate |
Definition at line 762 of file metric_exporters.h.
Referenced by convert_monitoring_data(), and convert_snapshot().

|
inlineprivate |
Definition at line 731 of file metric_exporters.h.
References config_, kcenon::monitoring::dependency_missing, kcenon::monitoring::metric_export_config::endpoint, kcenon::monitoring::metric_export_config::port, and transport_.
Referenced by export_metrics(), and export_snapshot().

|
inlineoverridevirtual |
Shutdown the exporter.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 708 of file metric_exporters.h.
References stop().
Referenced by TEST_F().


|
inlineoverridevirtual |
Start the exporter (for pull-based systems)
Reimplemented from kcenon::monitoring::metric_exporter_interface.
Definition at line 667 of file metric_exporters.h.
References config_, kcenon::monitoring::dependency_missing, kcenon::monitoring::metric_export_config::endpoint, kcenon::monitoring::metric_export_config::port, started_, and transport_.
Referenced by TEST_F().

|
inlineoverridevirtual |
Stop the exporter.
Reimplemented from kcenon::monitoring::metric_exporter_interface.
Definition at line 690 of file metric_exporters.h.
References started_, and transport_.
Referenced by shutdown(), and TEST_F().

|
private |
Definition at line 507 of file metric_exporters.h.
Referenced by convert_monitoring_data(), convert_snapshot(), export_metrics(), export_snapshot(), send_udp_batch(), and start().
|
private |
Definition at line 509 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_stats().
|
private |
Definition at line 510 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_stats().
|
private |
Definition at line 511 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_stats().
|
private |
|
private |
Definition at line 508 of file metric_exporters.h.
Referenced by get_stats(), send_udp_batch(), start(), and stop().