FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support forwarding arbitrary client kwargs to spanner.Client by oortega15 · Pull Request #196 · google/python-spanner-orm · GitHub

Support forwarding arbitrary client kwargs to spanner.Client - #196

Merged
oortega15 merged 10 commits into
mainfrom
support-disable-builtin-metrics
Aug 19, 2026
Merged

oortega15 merged 10 commits into
mainfrom
support-disable-builtin-metrics

Conversation

oortega15 commented Aug 12, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

Allows callers to pass arbitrary keyword arguments (**client_kwargs) through SpannerConnection, spanner_orm.connect(), and spanner_orm.admin.connect() to be forwarded directly to google.cloud.spanner.Client.

Motivation

Makes the client connection configurable and future-proof so callers can pass options such as disable_builtin_metrics (useful for silencing client telemetry export noise in recent google-cloud-spanner versions), route_to_leader_enabled, etc., without requiring ORM updates whenever new client parameters are introduced.

Testing

  • Added unit test in spanner_orm/tests/api_test.py verifying client kwargs forwarding.

Allow passing disable_builtin_metrics to SpannerConnection and connect helper functions to be forwarded to google.cloud.spanner.Client.

google-cla Bot commented Aug 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread spanner_orm/admin/api.py Outdated
create_ddl: Optional[Iterable[str]] = None) -> SpannerAdminApi:
create_ddl: Optional[Iterable[str]] = None,
*,
client_options: Union[api_client_options.ClientOptions,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why are we adding these 2 fields in?

If the goal is to just to support disable_builtin_metrics, then this PR should not be adding this in.

If the goal is to support all fields that the Spanner client supports, then the list is not exhaustive, see: https://docs.cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.client. There's several other fields that were not added.

I'm not sure what the best way to write this would be, we could either:

  • Declare every field and pass it in. This has issue that anytime Spanner updates their client, we also need to update our wrapper.
  • Use kwargs. This allows us to support new fields without needing a PR to update but has disadvantage of the IDE to pop up the available arguments for people who are depending on this library.

Personally, I'm fine with us just adding the disable_builtin_metrics but a lot of this depends on the maintenance status of this library.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Great point! Using **client_kwargs makes much more sense so the library remains future-proof and doesn't require a new PR whenever google-cloud-spanner adds or modifies client initialization arguments. I have updated the implementation to use **client_kwargs in SpannerConnection, spanner_orm.connect(), and spanner_orm.admin.connect(), forwarding them directly to spanner.Client. This supports disable_builtin_metrics (and any other client options) seamlessly.

…ssing arbitrary keyword arguments (**client_kwargs) through SpannerConnection, spanner_orm.connect(), and spanner_orm.admin.connect() to be forwarded directly to google.cloud.spanner.Client. This makes the ORM flexible and future-proof, allowing callers to configure options like disable_builtin_metrics, route_to_leader_enabled, etc.
…ssing arbitrary keyword arguments (**client_kwargs) through SpannerConnection, spanner_orm.connect(), and spanner_orm.admin.connect() to be forwarded directly to google.cloud.spanner.Client.
lirobert3 self-requested a review August 13, 2026 14:56
lirobert3 requested a review from dgorelik August 13, 2026 14:57

Copy link
Copy Markdown

CC: @dgorelik since I haven't reviewed code from this repo. Can you PTAL as well?

dgorelik 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

2 notes:

  • the PR title/description still refer to disable_builtin_metrics while I believe this change is more general
  • i would remove the jetski/gemini output re: changes/tests in the PR description, it's pretty redundant IMO

oortega15 changed the title Add support for disable_builtin_metrics in SpannerConnection and connect Support forwarding arbitrary client kwargs to spanner.Client Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

2 notes:

  • the PR title/description still refer to disable_builtin_metrics while I believe this change is more general
  • i would remove the jetski/gemini output re: changes/tests in the PR description, it's pretty redundant IMO

I have fixed these notes :D

oortega15 merged commit d841041 into main Aug 19, 2026
15 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL