Skip to content

test(spanner): reset tracing framework in tests to prevent state leakage - #14906

Open
olavloite wants to merge 1 commit into
mainfrom
spanner-prevent-trace-leakage
Open

olavloite wants to merge 1 commit into
mainfrom
spanner-prevent-trace-leakage

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Several tests configure OpenTelemetry tracing globally during execution. Without explicit teardown, this configuration persists across tests in the same test run and causes subsequent tests that expect the default tracing behavior to fail or behave inconsistently.

This change ensures that all tests enabling a custom tracing framework cleanly restore the default tracing state when they finish. Teardown routines are guarded so that unrelated errors during cleanup cannot bypass the reset, and tests defensively clear any preexisting state before enabling custom tracing.

@olavloite
olavloite requested review from a team as code owners November 3, 2026 14:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request synchronizes the resetActiveTracingFramework method in SpannerOptions and introduces teardown resets across various test classes to prevent tracing state leakage. The review feedback suggests using nested try-finally blocks in IntegrationTestEnv.after() to ensure all cleanup steps execute even if one fails, and defensively resetting the active tracing framework in @BeforeClass setup methods to avoid failures from state leakage of preceding tests.

@olavloite
olavloite force-pushed the spanner-prevent-trace-leakage branch from c8f7f64 to c399f93 Compare November 3, 2026 15:09
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request synchronizes the resetActiveTracingFramework method in SpannerOptions and updates various test suites to ensure the active tracing framework is properly reset during setup or teardown (often using @AfterClass or within finally blocks). The review feedback correctly identifies redundant @AfterClass teardown methods in ResumableStreamIteratorTest and GapicSpannerRpcTest, as their respective @After methods already handle resetting the active tracing framework after every test case.

Several tests configure OpenTelemetry tracing globally during execution.
Without explicit teardown, this configuration persists across tests in
the same test run and causes subsequent tests that expect the default
tracing behavior to fail or behave inconsistently.

This change ensures that all tests enabling a custom tracing framework
cleanly restore the default tracing state when they finish. Teardown
routines are guarded so that unrelated errors during cleanup cannot
bypass the reset, and tests defensively clear any preexisting state
before enabling custom tracing.
@olavloite
olavloite force-pushed the spanner-prevent-trace-leakage branch from c399f93 to f2b29fd Compare November 3, 2026 15:33
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request synchronizes the resetActiveTracingFramework method in SpannerOptions to ensure thread safety. Additionally, it updates various test classes to consistently reset the active tracing framework during teardown or setup phases, preventing state leakage between tests. There are no review comments to address, and the changes look solid.

This branch has not been deployed

No deployments
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.

1 participant