38 auto name() const -> std::string_view
override {
39 return "example_plugin";
52 auto collect() -> std::vector<metric_data>
override {
53 std::vector<metric_data> metrics;
60 metric_data cpu_metric;
61 cpu_metric.name =
"example.cpu_usage";
63 cpu_metric.unit =
"%";
64 cpu_metric.timestamp = std::chrono::system_clock::now();
65 cpu_metric.labels[
"plugin"] =
"example";
66 cpu_metric.labels[
"type"] =
"cpu";
67 metrics.push_back(cpu_metric);
69 metric_data memory_metric;
70 memory_metric.name =
"example.memory_usage";
72 memory_metric.unit =
"MB";
73 memory_metric.timestamp = std::chrono::system_clock::now();
74 memory_metric.labels[
"plugin"] =
"example";
75 memory_metric.labels[
"type"] =
"memory";
76 metrics.push_back(memory_metric);
78 metric_data counter_metric;
79 counter_metric.name =
"example.request_count";
81 counter_metric.unit =
"requests";
82 counter_metric.timestamp = std::chrono::system_clock::now();
83 counter_metric.labels[
"plugin"] =
"example";
84 counter_metric.labels[
"type"] =
"counter";
85 metrics.push_back(counter_metric);
96 return plugin_metadata_t{
97 plugin_category::custom,
98 plugin_type::collector,
101 "Demonstrates dynamic plugin loading"
107 std::uniform_real_distribution<double> dist(min, max);
121 "Example dynamically loaded collector plugin",
Example collector plugin that generates dummy metrics.
auto collect() -> std::vector< metric_data > override
Collect current metrics from this plugin.
auto initialize(const config_map &config) -> bool override
Initialize plugin with configuration.
uint64_t request_counter_
auto generate_random_value(double min, double max) -> double
auto shutdown() -> void override
Shutdown plugin and release resources.
auto get_metadata() const -> plugin_metadata_t override
Get plugin metadata.
auto name() const -> std::string_view override
Get the unique name of this plugin.
auto is_available() const -> bool override
Check if this plugin is available on the current system.
Pure virtual interface for metric collector plugins.
Plugin interface for metric collectors.
std::unordered_map< std::string, std::string > config_map
Type alias for configuration map.
C API for dynamically loaded collector plugins.