Skip to content

fix(tests): restore SDK tracer after full_stack fixture teardown - #629

Closed
syf2211 wants to merge 1 commit into
Metabuilder-Labs:mainfrom
syf2211:fix/581-full-stack-tracer-restore
Closed

fix(tests): restore SDK tracer after full_stack fixture teardown#629
syf2211 wants to merge 1 commit into
Metabuilder-Labs:mainfrom
syf2211:fix/581-full-stack-tracer-restore

Conversation

@syf2211

@syf2211 syf2211 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The full_stack integration fixture rebinds agent_mod._tracer to a fixture-local TracerProvider but never restored the original tracer after shutdown. Later tests in the same pytest process (notably tests/unit/test_ping.py) then routed spans through a shut-down provider, causing four ping tests to fail when tests/integration/ ran before tests/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

  • Tests pass (pytest tests/integration/test_full_pipeline.py tests/unit/test_ping.py — 21 passed; issue reproduction command now green)
  • Lint clean on changed file (ruff check tests/integration/test_full_pipeline.py — only pre-existing unused-import warnings in file header)
  • Type check clean (mypy tokenjam/)
  • CLAUDE.md updated (if architecture changed) — N/A
  • Test spans use tests/factories.py (not raw NormalizedSpan) — N/A
  • Requested @anilmurty as reviewer

Tests

  • pytest tests/integration/test_full_pipeline.py tests/unit/test_ping.py21 passed (was 4 failed before fix)
  • pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/ — 4340 passed, 5 failed (pre-existing unrelated failures in test_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.

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
@syf2211
syf2211 requested a review from anilmurty as a code owner July 27, 2026 18:10
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Restores the SDK module tracer after the full_stack integration fixture shuts down its fixture-local tracer provider, preventing state leakage into later tests.

Confidence Score: 5/5

The PR appears safe to merge.

The fixture now restores the shared SDK tracer after shutting down its local provider, addressing the reported cross-test contamination without changing production behavior.

Important Files Changed

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

@anilmurty

Copy link
Copy Markdown
Contributor

Thanks @syf2211 — this is a clean, correct fix (matches #581 exactly and is Rule #11-compliant: it swaps the module-level _tracer reference rather than re-calling set_tracer_provider). It turns out to be the same fix as #630 (@Axiya3749), filed against the duplicate issue #615, which just merged with a before/after reproduction (4 failures → 0). Closing this as a duplicate so we don't double-apply — genuinely appreciated, and your #633/#634 are in review. The shared bug is fixed on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_ping.py depends on suite run order: the full_stack fixture leaks a stale SDK tracer

2 participants