In this article
Collection callbacks belong to each reader; adding an export path can multiply device polling and expose stateful callback defects.
The diagnostic situation
A serving process exports metrics to a remote backend and adds a local diagnostic reader. Device polling suddenly increases although the application’s nominal metric interval was not changed. A callback that clears an internal counter also gives different results to each destination. The added reader changed collection behavior, not the model workload, and a shared mutable callback made the difference worse.
Why the observation changes meaning
The metrics SDK permits multiple readers on a provider and invokes asynchronous callbacks for the reader performing collection. A collection on one reader should not alter another reader’s SDK state. That does not make arbitrary user callbacks free of side effects. A callback that mutates external state or performs expensive device queries can change cost and observed values when collection frequency changes.
Define the instrumentation contract
Inventory all registered readers, their triggers and any manual collection or flush path. Define callback behavior as observation of state rather than destructive consumption of a shared application value. If a cached device snapshot is used, specify its freshness and ownership. Keep reader-specific aggregation intervals distinct; do not clear another reader’s delta merely because a local diagnostic export completed.
A bounded verification procedure
Build a test callback with an independent invocation ledger and a synthetic observable value. Collect through each reader separately and then through the intended combined configuration. Compare invocation counts, exported values and callback duration. Repeat with a manually triggered collection to expose invocation paths outside the nominal schedule. This tests collection mechanics without repeatedly polling a real production GPU or changing model traffic.
Evidence required for acceptance
Acceptance evidence includes reader configuration, collection trigger timeline, callback ledger and per-destination output. Show that adding the diagnostic reader does not destructively change another reader’s intended observations. Measure actual polling overhead if the callback performs device work, rather than assuming the export interval alone bounds it. Preserve failed collection outcomes independently from inference-request success.
Failure cases and limits
The exact scheduling and timeout interfaces vary by SDK language and release. A shared snapshot can reduce repeated polling but introduces staleness that must remain visible. This protocol validates callback ownership and side effects; it does not promise simultaneous readings across destinations or zero observability overhead. Application correctness and metric-delivery completeness still require separate checks beyond successful callback execution.
Primary references and related reading
Collection callbacks belong to each reader; adding an export path can multiply device polling and expose stateful callback defects. OpenTelemetry metrics SDK; OpenTelemetry metrics data model.
The proposed investigation of metric readers callback side effects is not an executed deployment benchmark. Related reading: OpenTelemetry Collector drops data during backend outages: queues and limits; Provider metric cardinality: request IDs do not belong in labels.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.