Skip to content

Conversation

@surbhigarg92
Copy link
Contributor

@surbhigarg92 surbhigarg92 commented Dec 9, 2025

BEGIN_COMMIT_OVERRIDE
fix: Provide option to disable metrics via SpannerOption.
Release-As: 3.60.0
END_COMMIT_OVERRIDE

@surbhigarg92 surbhigarg92 requested review from a team as code owners December 9, 2025 10:17
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/python-spanner API. labels Dec 9, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @surbhigarg92, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces enhanced control over the built-in metrics collection for the google-cloud-spanner client. It provides a direct option within the Client constructor to disable these metrics, complementing the existing environment variable mechanism. This change offers greater flexibility for users who need to manage or suppress metrics reporting in their applications.

Highlights

  • New disable_builtin_metrics option: A new optional boolean parameter, disable_builtin_metrics, has been added to the Client constructor. Setting this to True will prevent the collection and exporting of Spanner's built-in metrics.
  • Environment variable integration: The logic for enabling built-in metrics now also considers the SPANNER_DISABLE_BUILTIN_METRICS_ENV_VAR environment variable, allowing metrics to be disabled via either the constructor option or the environment variable.
  • Internal function renaming: The internal helper function _get_spanner_enable_builtin_metrics was renamed to _get_spanner_enable_builtin_metrics_env to more accurately reflect its purpose of checking environment variables.
  • Comprehensive unit tests: New unit tests have been added to ensure that both the disable_builtin_metrics constructor option and the SPANNER_DISABLE_BUILTIN_METRICS_ENV_VAR environment variable correctly disable the Spanner built-in metrics.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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 introduces a new option disable_builtin_metrics to the Spanner Client constructor, allowing users to programmatically disable the built-in metrics collection. The implementation correctly considers both this new option and the existing environment variable SPANNER_DISABLE_BUILTIN_METRICS. The changes are well-tested, though there is a minor issue in a test docstring. Overall, this is a good addition for providing more control over metrics.

Comment on lines +286 to +288
"""
Test that Client constructor disable metrics using Spanner Option.
"""

Choose a reason for hiding this comment

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

medium

The docstring seems to be a copy-paste from the test below. It should describe that this test validates disabling metrics via the environment variable, not the Spanner option.

Suggested change
"""
Test that Client constructor disable metrics using Spanner Option.
"""
"""
Test that Client constructor disables metrics using an environment variable.
"""

@surbhigarg92 surbhigarg92 merged commit f1ebc43 into main Dec 9, 2025
21 of 22 checks passed
@surbhigarg92 surbhigarg92 deleted the disable_metrics_option branch December 9, 2025 10:48
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 9, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 9, 2025
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 10, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 10, 2025
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 10, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 10, 2025
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 10, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 10, 2025
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 10, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 10, 2025
@surbhigarg92 surbhigarg92 added the release-please:force-run To run release-please label Dec 10, 2025
@release-please release-please bot removed the release-please:force-run To run release-please label Dec 10, 2025
gcf-merge-on-green bot pushed a commit that referenced this pull request Dec 10, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.

Librarian Version: v1.0.0
Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:8e2c32496077054105bd06c54a59d6a6694287bc053588e24debe6da6920ad91
<details><summary>google-cloud-spanner: 3.60.0</summary>

## [3.60.0](https://togithub.com/googleapis/python-spanner/compare/v3.59.0...v3.60.0) (2025-12-10)

### Features

* make built-in metrics enabled by default (#1459) ([64aebe7](https://togithub.com/googleapis/python-spanner/commit/64aebe7e))

* Exposing AutoscalingConfig in InstancePartition ([8b6f154](https://togithub.com/googleapis/python-spanner/commit/8b6f1540))

* add support for experimental host (#1452) ([9535e5e](https://togithub.com/googleapis/python-spanner/commit/9535e5e0))

* enable OpenTelemetry metrics and tracing by default (#1410) ([bb5095d](https://togithub.com/googleapis/python-spanner/commit/bb5095df))

* add cloud.region, request_tag and transaction_tag in span attributes (#1449) ([d37fb80](https://togithub.com/googleapis/python-spanner/commit/d37fb80a))

* Add QueryAdvisorResult for query plan (PiperOrigin-RevId: 832425466) ([e08260f](https://togithub.com/googleapis/python-spanner/commit/e08260fe))

* Add Send and Ack mutations for Queues (PiperOrigin-RevId: 832425466) ([e08260f](https://togithub.com/googleapis/python-spanner/commit/e08260fe))

* Add Spanner location API (#1457) (PiperOrigin-RevId: 833474957) ([e08260f](https://togithub.com/googleapis/python-spanner/commit/e08260fe))

### Bug Fixes

* Deprecate credentials_file argument ([8b6f154](https://togithub.com/googleapis/python-spanner/commit/8b6f1540))

* configure keepAlive time for gRPC TCP connections (#1448) ([efb2833](https://togithub.com/googleapis/python-spanner/commit/efb2833e))

* Provide Spanner Option to disable metrics (#1460) ([f1ebc43](https://togithub.com/googleapis/python-spanner/commit/f1ebc43b))

### Documentation

* Update description for the BatchCreateSessionsRequest and Session (PiperOrigin-RevId: 832425466) ([e08260f](https://togithub.com/googleapis/python-spanner/commit/e08260fe))

* Update description for the IsolationLevel (PiperOrigin-RevId: 832425466) ([e08260f](https://togithub.com/googleapis/python-spanner/commit/e08260fe))

</details>
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 googleapis/python-spanner API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants