-
Notifications
You must be signed in to change notification settings - Fork 100
feat(spanner): log client configuration at startup #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| _get_spanner_enable_builtin_metrics(), | |
| _get_spanner_enable_builtin_metrics_env(), |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
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