fix(spanner): resolve TypeError in metrics resource detection#1446
Merged
sinhasubham merged 2 commits intomainfrom Oct 18, 2025
Merged
fix(spanner): resolve TypeError in metrics resource detection#1446sinhasubham merged 2 commits intomainfrom
sinhasubham merged 2 commits intomainfrom
Conversation
f559b88 to
762d1de
Compare
tests/unit/test_client.py
Outdated
Contributor
There was a problem hiding this comment.
why is this required?
Contributor
Author
There was a problem hiding this comment.
This change got included by mistake in the PR. I was testing something locally as i felt 'read_lock_mode="PESSIMISTIC"' might not be required here. Removed it for now.
762d1de to
ebb4883
Compare
| SpannerMetricsTracerFactory() | ||
| except Exception as e: | ||
| log.warning( | ||
| "Failed to initialize Spanner built-in metrics. Error: %s", e |
Contributor
There was a problem hiding this comment.
Suggested change
| "Failed to initialize Spanner built-in metrics. Error: %s", e | |
| "Failed to initialize Spanner client side metrics. Error: %s", e |
surbhigarg92
approved these changes
Oct 17, 2025
sakthivelmanii
approved these changes
Oct 17, 2025
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: fix(spanner): resolve TypeError in metrics resource detection
Root cause:
The metrics tracer factory was attempting to access the
cloud.regionattribute directly from an OpenTelemetryResourceobject using dictionary-style subscription (resource['key']).However, the
Resourceobject is not subscriptable. The correct way to access its attributes is through the.attributesproperty (resource.attributes['key']).This change corrects the access pattern, resolving a
TypeErrorthat would crash applications uponspanner.Clientinitialization when built-in metrics were enabled in a GCP environment.Testing
Tested by replicating the error locally using this script.