Skip to content

chore(spanner): implement shutdown and Drop handler for Observability meter provider - #6246

Open
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-built-in-metrics-shutdown
Open

chore(spanner): implement shutdown and Drop handler for Observability meter provider#6246
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-built-in-metrics-shutdown

Conversation

@olavloite

Copy link
Copy Markdown
Contributor
  • Add explicit Observability::shutdown(&self) method to shut down the underlying OpenTelemetry SdkMeterProvider, flushing pending metric data points and stopping periodic reader background tasks.
  • Implement Drop for Observability so telemetry resources are cleanly released when clients are closed or dropped.
  • Ignore OTelSdkError::AlreadyShutdown on repeated calls to shutdown(&self) to prevent false-positive warning logs.

… meter provider

- Add explicit `Observability::shutdown(&self)` method to shut down the underlying OpenTelemetry `SdkMeterProvider`, flushing pending metric data points and stopping periodic reader background tasks.
- Implement `Drop` for `Observability` so telemetry resources are cleanly released when clients are closed or dropped.
- Ignore `OTelSdkError::AlreadyShutdown` on repeated calls to `shutdown(&self)` to prevent false-positive warning logs.
@olavloite
olavloite requested review from a team as code owners July 31, 2026 15:17
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Jul 31, 2026

@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 implements graceful shutdown and resource cleanup for the OpenTelemetry SdkMeterProvider in the Spanner observability module. It renames _meter_provider to meter_provider, implements a shutdown method that handles AlreadyShutdown errors, and implements the Drop trait to automatically trigger shutdown when Observability is dropped. Additionally, new unit tests are added to verify the shutdown and drop behaviors. I have no feedback to provide as the changes are well-implemented and include appropriate test coverage.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.07%. Comparing base (93d9a0f) to head (d900134).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6246   +/-   ##
=======================================
  Coverage   96.07%   96.07%           
=======================================
  Files         273      273           
  Lines       68742    68766   +24     
=======================================
+ Hits        66042    66066   +24     
  Misses       2700     2700           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@olavloite
olavloite requested a review from sakthivelmanii July 31, 2026 17:44
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