telemetry: add per-metric activation (NIX-453) (#1919)
## What? Adds **per-metric activation** for telemetry via `NIXL_TELEMETRY_METRICS` — a comma-separated glob allowlist (POSIX `fnmatch`, e.g. `agent_tx_bytes`, `agent_err_*`) selecting which metrics are exported. - Resolved **once at construction** into an enum-indexed mask. - **Gated at the producer**: `updateData()` / `addXferStats()` skip deactivated metrics *before the staging queue*, so a deactivated metric costs no mutex/append on the transfer hot path and is never counted as a drop. The check is a single lock-free read of the immutable mask (`isMetricEnabled`). - **Unset/empty = all metrics active** (backward compatible); a token matching nothing is ignored with a warning. - `getXferTelemetry()` is unaffected (reads the request handle, not the queue). Docs (`docs/telemetry.md`, prometheus/doca/plugin READMEs) and tests updated in the same PR. ## Why? Tracked by NIX-453 (parent NIX-1423): operators need to enable/disable individual telemetry metrics without turning telemetry off. Gating at the source (rather than at drain) means deactivated metrics incur zero hot-path cost — per review feedback from @AlexNvd. This is **Phase 1** — event-type granularity, core-only, collision-free with the in-flight histogram PR #1914. **Phase 2** (NIX-1612: per-series / histogram-group control, `*_us`/`*_total` globs) lands after #1914. ## How? - `telemetry_event.h`: `nixl_telemetry_event_type_count` + `nixl_telemetry_metric_mask_t` alias (append-only; no descriptor changes). - `telemetry.cpp`: `resolveEnabledMetrics()` parses `NIXL_TELEMETRY_METRICS` (`absl::StrSplit` + `fnmatch`) into the mask; `updateData()`/`addXferStats()` gate on `isMetricEnabled` before staging; `flushPendingEvents()` no longer filters. - Tests (gtest, 33/33): producer-gating cases (subset, family glob, unknown-token) on the BUFFER stream + an end-to-end Prometheus scrape case. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added `NIXL_TELEMETRY_ENABLED_METRICS` to restrict exported telemetry using a comma-separated POSIX-glob allowlist (selects whole metric families). * **Bug Fixes** * Deactivated metrics are filtered out before buffering/staging, and the “telemetry dropped” event is emitted only when enabled. * **Tests** * Added Prometheus and buffer-export allowlist tests (subset, family globs, and unknown tokens). Added a disabled performance benchmark for fully deactivated per-transfer stats. * **Documentation** * Updated telemetry and exporter docs to cover matching rules, warnings for unmatched tokens, and default “export all” behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Efraim Eygin <eeygin@nvidia.com>
E
e-eygin committed
bdedb9ce17bb6e439340802db6a35243cf4e6feb
Parent: b594eb0
Committed by GitHub <noreply@github.com>
on 7/14/2026, 7:33:16 PM