test: drive prometheus_mp through nixlTelemetry (#2054)
## What? Covers the `prometheus_mp` telemetry exporter's core path in gtest by driving it through `nixlTelemetry` instead of calling `exportEvent` directly: the per-metric allowlist keeping a deactivated metric out, the dropped-events counter accumulating every flush delta, and conservation of accepted + dropped events when a small staging queue overflows (both the single-event path and the all-or-none 4-event `addXferStats` batch). Tests only; no production code changes. ## Why? Everything this exporter had constructed it directly and called `exportEvent`, which skips the core: the staging queue, the drain task, metric gating and the drop accounting were never exercised for it. NIX-1685 makes `prometheus_mp` the configured exporter everywhere, and an exporter should not become a default while its core path is untested. The allowlist is the case that matters most. Per-metric activation gates producer-side, before the staging queue, so it *should* apply identically to any exporter — but nothing proved a deactivated metric stays out of an mp store, and NIX-1685 would make that a default-path behaviour. Closes NIX-1682. ## How? These tests need an HTTP scrape and a way to query the parsed result. Three implementations of that already existed: two hand-rolled ones in gtest (string matching over the raw body) and a proper loopback client, OpenMetrics parser and series-query layer in the DOCA tests. Rather than add a fourth, the DOCA one moved to `test/metrics/` as the shared toolkit and the gtest telemetry tests were converted onto it, which deleted more code than the new tests add. Waiting on an expected end state rather than sleeping a fixed interval is what keeps the new tests timing-independent, and it also cut suite runtime. The mp fixtures got the same treatment: four suites each opened their own per-test temp directory, two of them separately repeating the mode-0700 chmod the exporter needs in order not to warn (a warning fails these tests), so that rule now lives in one place. Descriptors are owned by `nixl::scopedFd` rather than hand-rolled closers. The allowlist test asserts on the store snapshot as well as on the scrape: an untouched slot proves the event never reached the exporter, rather than merely not being rendered. Verified with `./build/test/gtest/gtest --gtest_filter='Mp*:*Prometheus*:*Telemetry*'` (88/88, stable over `--gtest_repeat=5`) and the DOCA telemetry targets, which exercise the moved scrape toolkit. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Expanded multi-process telemetry coverage for metric filtering, dropped-event accounting, overflow conservation, histogram data, and stale-process cleanup. - Improved validation of Prometheus metrics, labels, counters, gauges, and histograms. - Added shared test utilities for scraping, parsing, temporary resources, and telemetry setup. - **Refactor** - Consolidated telemetry test helpers under a shared metrics-testing framework. - Improved socket and file-descriptor cleanup through automatic resource management. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Efraim Eygin <eeygin@nvidia.com>
E
e-eygin committed
e1cbabcaae9cb52efc54c96c138815598204a656
Parent: 4e50bc3
Committed by GitHub <noreply@github.com>
on 8/18/2026, 10:24:08 AM