fix(tests): reset OTel tracer provider to None to stop cross-test recursion - #336
Merged
Merged
Conversation
…ursion The reset_otel_providers autouse fixture reset the global tracer provider to a fresh ProxyTracerProvider() after each test. A ProxyTracerProvider delegates get_tracer() to the module-global trace._TRACER_PROVIDER; once that global *is* a ProxyTracerProvider, the delegation points back at itself and start_as_current_span recurses until RecursionError. Because the fixture mutates OTel's process-global state, the broken provider leaked out of the opentelemetry test package into the rest of the suite. Later tests that emit spans (orchestrator_tracing, execution_tracing) hit the RecursionError inside operation_span; the orchestrator swallowed it as a processing error, so container executions were driven to SYSTEM_ERROR instead of their expected states. This surfaced as 6 unrelated-looking failures in test_container_execution_refresh_retries and test_orchestrator_failed_log_upload only when the full suite ran. Reset to None (matching the meter-provider reset on the next line) so get_tracer_provider() falls back to the internal proxy and ProxyTracer resolves to the no-op tracer. Full suite: 468 passed.
yuechao-qin
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running the full
tests/suite produced 6 failures that were not reproducible when the affected files were run in isolation:The failures were a symptom (
SYSTEM_ERRORinstead ofPENDING, mocks never called, timestamps not advancing), with aRecursionError: maximum recursion depth exceededburied in the output.Root cause
The
reset_otel_providersautouse fixture in tests/instrumentation/opentelemetry/conftest.py reset the global tracer provider to a freshProxyTracerProvider():OpenTelemetry's
ProxyTracerProvider.get_tracer()delegates to the module-globaltrace._TRACER_PROVIDER. Once that global is aProxyTracerProvider, the delegation points back at itself, sostart_as_current_spanrecurses untilRecursionError.Because the fixture mutates OTel's process-global state, the broken provider leaked out of the
opentelemetry/test package into the rest of the suite (default collection order runs it beforetest_container_execution_refresh_retries). Later tests that emit spans viaorchestrator_tracing.operation_span/execution_tracing.emit_execution_tracehit theRecursionError; the orchestrator caught it as a generic processing error and drove container executions toSYSTEM_ERROR, which is what the assertions actually tripped on.Fix
Reset to
None, matching the meter-provider reset on the very next line:With
None,get_tracer_provider()falls back to OTel's internal_PROXY_TRACER_PROVIDERandProxyTracerresolves to the no-op tracer — no self-delegation, no recursion.Verification
6 failed, 462 passed(full suite)468 passed(full suite,pytest tests/)opentelemetry/suite that owns the fixture continues to pass.Downstream
This is beneficial to downstream applications with their own suite of tests against OTEL.