Repository navigation
fix(sdk): register processor queue capacity as observable up-down counter - #5896
hardikkaurani wants to merge 3 commits into
Conversation
|
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-11-11 10:06 UTC Review the latest changes. Status above doesn't look right?
|
|
Hi @herin049, could you please take a look at this PR when you have some time? This resolves #5891 by registering This ensures queue capacity is observed across all collection cycles under Thanks! |
…nd fix changelog fragment
|
I reviewed the changes and tested the new callback behavior against the proxy meter and temporality flows. Switching A few specific observations from tracing the implementation:
The change is focused, backward-compatible, and the regression tests cover both traces and logs across all collection phases. |
|
Thanks so much for taking the time to review and test this out, @knowprasad! Really appreciate the detailed feedback and verification on the proxy meter and temporality flows. |
sangkyoonnam
left a comment
There was a problem hiding this comment.
LGTM. The callback mirrors register_queue_size, and the proxy test covers the #5891 case where the processor is built before set_meter_provider.
Small thing on test_queue_capacity_delta_temporality: it sets DELTA only for UpDownCounter, which doesn't apply to the capacity instrument anymore, so what it really shows is that the new instrument ignores that setting. Worth saying that in the test name or a comment?
…comments Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Thanks for the review and suggestion, @sangkyoonnam! Good point — that test specifically reproduces the reader configuration from #5891 ( I have updated the test in both
Pushed in commit f403173. |
Description
This pull request fixes missing and inconsistent reporting of processor queue capacity metrics in the OpenTelemetry Python SDK.
Previously,
otel.sdk.processor.span.queue.capacityandotel.sdk.processor.log.queue.capacitywere implemented as synchronousUpDownCounterinstruments and recorded only once during processor initialization. This caused incorrect metric behavior in two scenarios:BatchSpanProcessororBatchLogRecordProcessorwas created beforemetrics.set_meter_provider()was called, the global meter provider could still be a_ProxyMeterProvider. Its proxy instrument discarded the initial measurement without replaying it when the actualMeterProviderwas registered.AggregationTemporality.DELTA, the one-time.add(capacity)measurement was reported during the initial collection but disappeared from subsequent collection cycles.This change registers both queue capacity metrics as asynchronous
ObservableUpDownCounterinstruments, ensuring the configured capacity is observed during metric collection rather than recorded only once during initialization.Changes
opentelemetry/sdk/_internal/metrics.pyUpDownCounterregistration with asynchronousObservableUpDownCounterregistration.Observation.tests/sdk/_logs/test_export.pyMeterProvider.DELTAaggregation temporality across consecutive collection cycles.tests/sdk/trace/export/test_export.pyBatchSpanProcessor.MeterProviderinitialization and across repeated metric collections.Validation
MeterProviderinitialization.AggregationTemporality.DELTA.Motivation
Queue capacity is a configuration metric that should remain observable throughout the processor's lifecycle. Using an asynchronous observable instrument avoids losing the initial measurement when the global
MeterProvideris initialized later and ensures the metric remains available across collection cycles.