refactor(agent): serve /metrics through the shared metrics-endpoint crate#3525
Conversation
…rate The agent stood up its own axum server for `/metrics` -- a `spawn_prometheus_metrics_server` wrapper plus a `get_metrics_router`/`export_metrics` pair that hand-encoded the registry. That is exactly what the shared `metrics-endpoint` crate already does for the rest of the fleet, so this hands the agent's existing Prometheus registry to `metrics_endpoint::run_metrics_endpoint` and deletes the bespoke server. - The metrics listener now builds a `MetricsEndpointConfig` over `get_prometheus_registry()` and serves it, keeping the same bind address and the same fire-and-forget task. - `spawn_prometheus_metrics_server`, `get_metrics_router`, and `export_metrics` are gone, along with their now-unused axum and encoder imports. - The meter setup -- the `InstrumentationSingleton` and its custom network and retry views -- is untouched, so the exposed series are unchanged. The endpoint serves the same registry through the same `TextEncoder`, so `/metrics` stays byte-identical; it also answers `/health`, `/ready`, and `/` on the same port, matching the other migrated services. Tests pass! This supports NVIDIA#3180 Signed-off-by: Chet Nichols III <chetn@nvidia.com>
|
@coderabbitai full_review, thanks! |
|
(=^・ω・^=) ✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Summary by CodeRabbit
WalkthroughThe agent adds shared ChangesAgent metrics and tracing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant AgentSetup
participant PrometheusRegistry
participant MetricsEndpoint
AgentSetup->>PrometheusRegistry: get_prometheus_registry()
AgentSetup->>MetricsEndpoint: run_metrics_endpoint(config, registry)
MetricsEndpoint-->>AgentSetup: Serve metrics endpoint
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
The agent stood up its own axum server for
/metrics-- aspawn_prometheus_metrics_serverwrapper plus aget_metrics_router/export_metricspair that hand-encoded the registry. That is exactly what the sharedmetrics-endpointcrate already does for the rest of the fleet, so this hands the agent's existing Prometheus registry tometrics_endpoint::run_metrics_endpointand deletes the bespoke server.MetricsEndpointConfigoverget_prometheus_registry()and serves it, keeping the same bind address and the same fire-and-forget task.spawn_prometheus_metrics_server,get_metrics_router, andexport_metricsare gone, along with their now-unused axum and encoder imports.InstrumentationSingletonand its custom network and retry views -- is untouched, so the exposed series are unchanged.The endpoint serves the same registry through the same
TextEncoder, so/metricsstays byte-identical; it also answers/health,/ready, and/on the same port, matching the other migrated services.This supports #3180