fix(tests): restore SDK tracer after full_stack fixture teardown - #629
fix(tests): restore SDK tracer after full_stack fixture teardown#629syf2211 wants to merge 1 commit into
Conversation
The integration full_stack fixture reassigned agent_mod._tracer to a fixture-local TracerProvider but never restored the original tracer after shutdown. Later tests in the same pytest process (e.g. test_ping.py) then routed spans through a shut-down provider. Save and restore the module tracer in teardown, matching the pattern used in tests/agents/test_record_outcome.py. Fixes Metabuilder-Labs#581
|
| Filename | Overview |
|---|---|
| tests/integration/test_full_pipeline.py | Saves the original module tracer before rebinding it and restores it during fixture teardown; no actionable issues identified. |
Reviews (1): Last reviewed commit: "fix(tests): restore SDK tracer after ful..." | Re-trigger Greptile
|
Thanks @syf2211 — this is a clean, correct fix (matches #581 exactly and is Rule #11-compliant: it swaps the module-level |
Summary
The
full_stackintegration fixture rebindsagent_mod._tracerto a fixture-localTracerProviderbut never restored the original tracer after shutdown. Later tests in the same pytest process (notablytests/unit/test_ping.py) then routed spans through a shut-down provider, causing four ping tests to fail whentests/integration/ran beforetests/unit/.Save and restore the module tracer in teardown, matching the pattern already used in
tests/agents/test_record_outcome.py.Related issue
Closes #581
Checklist
pytest tests/integration/test_full_pipeline.py tests/unit/test_ping.py— 21 passed; issue reproduction command now green)ruff check tests/integration/test_full_pipeline.py— only pre-existing unused-import warnings in file header)mypy tokenjam/)tests/factories.py(not rawNormalizedSpan) — N/A@anilmurtyas reviewerTests
pytest tests/integration/test_full_pipeline.py tests/unit/test_ping.py— 21 passed (was 4 failed before fix)pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/— 4340 passed, 5 failed (pre-existing unrelated failures intest_backfill_progress.py,test_quickstart.py,test_sdk_config_discovery.py)Notes
Reviewed with composer-2.5: APPROVE. Minimal three-line fix; teardown order (
provider.shutdown()then restore) is correct.