chore(spanner): detect client location for built-in metrics and align client_hash - #6445
chore(spanner): detect client location for built-in metrics and align client_hash#6445olavloite wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic GCP client location detection for Spanner metrics by querying the Google Cloud Metadata Server (MDS) or environment variables, caching the result process-wide. It also updates the client hash generation to use a 10-bit prefix to reduce resource cardinality. The feedback suggests adding a short connection timeout to the metadata service HTTP client to prevent startup delays when running in non-GCP environments where the metadata server is unreachable.
af407ef to
4ad9500
Compare
… client_hash Detect the client location (e.g. `us-central1`) for Spanner built-in metrics using environment variables or the GCP metadata server, falling back to `global` if unreachable or when using the emulator. The detected location is cached so it is only fetched once per process. Also update `client_hash` to use the 10 most significant bits of the hash to keep resource cardinality within Cloud Monitoring limits.
4ad9500 to
206c24f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6445 +/- ##
==========================================
+ Coverage 96.09% 96.11% +0.01%
==========================================
Files 289 289
Lines 77540 77720 +180
==========================================
+ Hits 74514 74699 +185
+ Misses 3026 3021 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…st (#6446) Re-export `reqwest::Client` and `reqwest::ClientBuilder` from `gaxi::http::reqwest`. It does not bump the gax-internal version number, as that version has already been updated for the next release by other pull requests. This allows client libraries to construct HTTP clients with custom connection timeouts (such as for querying the Compute Engine Metadata Service) without declaring direct dependencies on `reqwest`. Needed for #6445
Do not merge: Needs #6446 first
Detect the client location (e.g.
us-central1) for Spanner built-in metrics using environment variables or the GCP metadata server, falling back toglobalif unreachable or when using the emulator. The detected location is cached so it is only fetched once per process.Also update
client_hashto use the 10 most significant bits of the hash to keep resource cardinality within Cloud Monitoring limits.