observability/testing/exemplars_test.go calls otel.SetTracerProvider without restoring the previous global. Installing a tracer provider process-wide and leaving it installed means a later test in the same binary observes a provider it never configured — the same leaked-global class as the t.Cleanup ordering defect fixed in the lane-contract fixture, where an assertion ordered before the restores could Goexit past them and leave a shut-down provider in place.
Why it isn't fixed inline
It was found by CodeRabbit while reviewing the streams-migration PR, whose diff spans the whole stack. The line itself lives on a branch below three PRs that were already approved and gated. Fixing it there would restack the stack, invalidate three sets of gates, and require fresh reviews — and CodeRabbit's review allowance is the binding constraint on that stack landing. For a test-hygiene issue bounded to one package's own test file, an issue is the better trade than a restack; for a correctness issue it would not have been.
The fix
Save the previous provider and restore it in t.Cleanup, ordering the restore before any assertion in that cleanup — an assertion that fails first will Goexit and skip everything after it. The lane-contract fixture already has the corrected shape to copy.
Worth checking at the same time
Whether any other test in the repo installs a global OTel provider without restoring it: git grep -n 'otel.Set' -- '*_test.go'.
observability/testing/exemplars_test.gocallsotel.SetTracerProviderwithout restoring the previous global. Installing a tracer provider process-wide and leaving it installed means a later test in the same binary observes a provider it never configured — the same leaked-global class as thet.Cleanupordering defect fixed in the lane-contract fixture, where an assertion ordered before the restores couldGoexitpast them and leave a shut-down provider in place.Why it isn't fixed inline
It was found by CodeRabbit while reviewing the streams-migration PR, whose diff spans the whole stack. The line itself lives on a branch below three PRs that were already approved and gated. Fixing it there would restack the stack, invalidate three sets of gates, and require fresh reviews — and CodeRabbit's review allowance is the binding constraint on that stack landing. For a test-hygiene issue bounded to one package's own test file, an issue is the better trade than a restack; for a correctness issue it would not have been.
The fix
Save the previous provider and restore it in
t.Cleanup, ordering the restore before any assertion in that cleanup — an assertion that fails first willGoexitand skip everything after it. The lane-contract fixture already has the corrected shape to copy.Worth checking at the same time
Whether any other test in the repo installs a global OTel provider without restoring it:
git grep -n 'otel.Set' -- '*_test.go'.