Skip to main content

Module plugin_metrics

Module plugin_metrics 

Source
Expand description

Phase 81.33.b.real Stage 5 — daemon-side plugin metrics scrape.

Plugins declare [plugin.metrics] prometheus = true + broker_topic_prefix = "...". The daemon’s /metrics handler iterates the registered scrape descriptors on every request, issues <broker_topic_prefix>.metrics.scrape broker RPC, and concatenates the returned Prometheus text into the aggregate response.

Replaces the previous pattern where each plugin’s metrics call was hardcoded inside run_metrics_server (e.g. the legacy nexo_plugin_email::metrics::render_prometheus(...) direct call).

§Wire format

Daemon → plugin on <broker_topic_prefix>.metrics.scrape:

{}

Plugin replies:

{ "text": "# HELP <metric_name> ...\n# TYPE ...\n<metric> <value>\n..." }

Empty / missing text is treated as a successful scrape with no metrics. Plugins that fail to respond (timeout, broker error, malformed reply) are skipped with a warn-level log — one slow plugin does NOT stall the aggregate response.

Structs§

PluginMetricsDescriptor
One entry per plugin opting into metrics scrape.

Enums§

PluginMetricsScrapeError

Functions§

scrape_all
Scrape every declaring plugin in parallel and return the concatenated Prometheus text. Plugins that fail (timeout, broker error, malformed reply) contribute the empty string
scrape_one
Scrape a single plugin. Used by scrape_all internally; exposed for callers that want fine-grained control (e.g. admin RPC /metrics/per_plugin follow-up).