Skip to content

fix(spanner): clear metrics tracers after operation completion#8172

Open
rahul2393 wants to merge 1 commit intomainfrom
fix-spanner-metrics-tracer-cleanup
Open

fix(spanner): clear metrics tracers after operation completion#8172
rahul2393 wants to merge 1 commit intomainfrom
fix-spanner-metrics-tracer-cleanup

Conversation

@rahul2393
Copy link
Copy Markdown
Contributor

@rahul2393 rahul2393 commented May 5, 2026

Summary

  • Fix MetricsTracerFactory.clearCurrentTracer() to handle already-extracted operation request IDs
  • Add a unit test covering cleanup with an extracted operation request ID
  • Prevent completed metrics tracers from staying in _currentOperationTracers until periodic cleanup

Why

createMetricsTracer() stores tracers by extracted operation request ID. Later, MetricsTracer.recordOperationCompletion() calls clearCurrentTracer() with that already-extracted ID.

clearCurrentTracer() attempted to extract again, failed to match the regex, and used an empty key. The stored tracer
was not removed, so _currentOperationTracers and _currentOperationLastUpdatedMs grew with every operation until the 60-minute cleanup threshold.

Allow MetricsTracerFactory.clearCurrentTracer to accept the already-extracted operation request id stored on MetricsTracer. This ensures completed operations remove their tracer entries instead of retaining them until the periodic cleanup threshold.
@rahul2393 rahul2393 requested a review from a team as a code owner May 5, 2026 15:42
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label May 5, 2026
Copy link
Copy Markdown
Contributor

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

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 updates the clearCurrentTracer method in MetricsTracerFactory to use the requestId as a fallback if the operation request extraction fails. It also includes a new test case to ensure that tracers and their associated metadata are correctly removed from internal maps when clearing. I have no feedback to provide as there were no review comments to evaluate.

@rahul2393 rahul2393 requested a review from surbhigarg92 May 5, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant