chore(spanner): add client identity and monitored resource attributes to built-in metrics - #6245
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces client-side metrics for Spanner observability by parsing database components, generating unique client identifiers (client_uid and client_hash), and attaching common attributes to metrics. Feedback suggests improving the client_hash calculation to use the 24 least significant bits of the FNV-1a hash to reduce collisions, and optimizing client_name to return a static string slice (&'static str) using the concat! macro to avoid unnecessary runtime allocations.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6245 +/- ##
========================================
Coverage 96.05% 96.06%
========================================
Files 271 271
Lines 68537 68649 +112
========================================
+ Hits 65835 65946 +111
- Misses 2702 2703 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… to built-in metrics - Add `parse_database_name`, `generate_client_uid`, `generate_client_hash`, and `client_name` helper functions for Spanner built-in metrics. - Attach an OpenTelemetry `Resource` (`project_id`, `instance_id`, `location`, `instance_config`, `client_hash`) to `SdkMeterProvider` in `Observability::init` so metrics export with correct `spanner_instance` resource labels. - Pre-construct common metric attributes (`client_uid`, `client_name`, `database`) on the `Observability` struct and include them on operation and attempt recordings without repeated string cloning. - Add comprehensive unit tests for database name parsing, deterministic client hashing, and client UID/name formatting.
85138f7 to
3ffbd7d
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces experimental built-in metrics support for the Spanner client by adding the uuid dependency and implementing helper functions to parse database names, generate unique client identifiers, and compute client hashes. The Observability struct is updated to initialize and attach these common attributes to recorded metrics, supported by new unit tests. There are no review comments, and the changes conform to the repository's style guidelines.
parse_database_name,generate_client_uid,generate_client_hash, andclient_namehelper functions for Spanner built-in metrics.Resource(project_id,instance_id,location,instance_config,client_hash) toSdkMeterProviderinObservability::initso metrics export with correctspanner_instanceresource labels.client_uid,client_name,database) on theObservabilitystruct and include them on operation and attempt recordings without repeated string cloning.