Skip to content

Conversation

@sinhasubham
Copy link
Contributor

This change introduces logging for Spanner client options upon initialization.

This allows customers to easily capture and inspect the configuration being used, which is valuable for debugging and verification.

This feature mirrors the existing logSpannerOptions functionality in the Java client, improving consistency across client libraries. googleapis/java-spanner#4141

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

Summary of Changes

Hello @sinhasubham, 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 a new feature to the Spanner client library that logs its configuration details upon initialization. This enhancement aims to improve the user experience by providing immediate and clear insight into the client's operational parameters, which is invaluable for diagnosing issues and confirming desired settings. The change also contributes to greater consistency across Google Cloud client libraries by mirroring functionality already present in the Java Spanner client.

Highlights

  • Client Configuration Logging: Implemented logging of Spanner client options during initialization to provide immediate visibility into the client's setup.
  • Enhanced Debugging and Verification: Enables easier debugging and verification of client configurations for users by exposing critical setup parameters.
  • Cross-Client Consistency: Aligns the Python client's behavior with the existing logSpannerOptions functionality found in the Java client library, promoting consistency across client ecosystems.
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 logging for Spanner client options at startup, which is a great enhancement for debuggability. The implementation is mostly solid, and the tests are comprehensive. However, I've found a critical bug due to a function name typo that will cause a NameError on client initialization. I've also provided a suggestion to improve the clarity of the host resolution logic. Once the critical issue is addressed, this will be a valuable addition.

self._directed_read_options,
self._default_transaction_options,
self._observability_options,
_get_spanner_enable_builtin_metrics(),

Choose a reason for hiding this comment

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

critical

There's a typo in the function call _get_spanner_enable_builtin_metrics(). The correct function name, as defined in this file, is _get_spanner_enable_builtin_metrics_env(). This typo will cause a NameError when a Client instance is initialized.

Suggested change
_get_spanner_enable_builtin_metrics(),
_get_spanner_enable_builtin_metrics_env(),

Comment on lines +299 to +305
host = "spanner.googleapis.com"
if self._client_options and self._client_options.api_endpoint:
host = self._client_options.api_endpoint
if self._emulator_host:
host = self._emulator_host
if self._experimental_host:
host = self._experimental_host

Choose a reason for hiding this comment

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

medium

The logic to determine the host can be made clearer and more robust by using an if/elif/else structure. This explicitly shows the precedence of different host configurations (_experimental_host > _emulator_host > api_endpoint) and avoids potential confusion from sequential if statements.

Consider refactoring this block to something like:

if self._experimental_host:
    host = self._experimental_host
elif self._emulator_host:
    host = self._emulator_host
elif self._client_options and self._client_options.api_endpoint:
    host = self._client_options.api_endpoint
else:
    host = "spanner.googleapis.com"

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: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants