chore(spanner): add initial setup for built-in metrics#5967
Conversation
Sets up the initial boiler-plate code for adding built-in metrics for Spanner. The feature is hidden behind a feature flag, meaning that it is currently invisible to customers.
There was a problem hiding this comment.
Code Review
This pull request introduces an experimental built-in metrics and observability framework for the Spanner client, adding dependencies on google-cloud-monitoring-v3 and opentelemetry to trace database operations. The reviewer feedback focuses on managing these new dependencies via cfg(google_cloud_unstable_tracing) flags instead of standard Cargo features to prevent dependency bloat, and conditionally compiling the observability module. Additionally, the reviewer recommends optimizing performance by using &'static str for method names to avoid unnecessary string allocations, and improving the robustness of the Server-Timing header parser to handle parameters in any order, along with adding corresponding test cases.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5967 +/- ##
==========================================
- Coverage 97.73% 97.65% -0.08%
==========================================
Files 244 246 +2
Lines 61161 61428 +267
==========================================
+ Hits 59776 59989 +213
- Misses 1385 1439 +54 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces observability and metrics support to the Spanner client, integrating OpenTelemetry and exporting metrics to Google Cloud Monitoring under the google_cloud_unstable_tracing feature flag. The review feedback highlights critical compilation errors in metrics.rs regarding universe_domain cloning and tonic::Status code retrieval, as well as a potential lifetime issue in the define_idempotent_rpc macro closure. Additionally, improvements are suggested to preserve universe domain resolution by not hardcoding the monitoring endpoint, use the crate name for the meter, enhance readability in server timing parsing, and adhere to the repository's 'return early' style guide in parse_project_id.
6589d88 to
abbeb89
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces observability and metrics tracking to the Spanner client using OpenTelemetry and Google Cloud Monitoring. It adds a new observability module, defines Spanner-specific metrics (such as operation and attempt latencies), and integrates these metrics across various transactions and client operations. The review feedback suggests optimizing environment variable parsing in metrics.rs by using eq_ignore_ascii_case instead of to_lowercase() to avoid unnecessary string allocations.
abbeb89 to
42bbe04
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces observability and metrics tracking to the Spanner client under the google_cloud_unstable_tracing feature flag, integrating OpenTelemetry and Google Cloud Monitoring to record operation and attempt latencies. The review feedback highlights a critical compilation error in the status-to-string mapping due to private tonic::Status fields and a missing name() method on tonic::Code. Additionally, it is recommended to propagate more configuration options, such as the emulator endpoint, from ClientConfig when initializing the monitoring service.
42bbe04 to
ee92ecb
Compare
|
/gemini review |
ee92ecb to
0fb4b96
Compare
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
0fb4b96 to
f599240
Compare
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces experimental built-in metrics support for the Spanner client, gated behind the experimental-builtin-metrics feature. It adds dependencies on opentelemetry, opentelemetry_sdk, and google-cloud-monitoring-v3, and implements an observability layer to track operation and attempt latencies and counts. Feedback on the changes points out a compilation issue in metrics.rs where PeriodicReader::builder is called with only one argument instead of also requiring a runtime argument like opentelemetry_sdk::runtime::Tokio.
| unstable-stream = ["dep:futures"] | ||
| default-rustls-provider = ["gaxi/_default-rustls-provider"] | ||
| unstable-stream = ["dep:futures"] | ||
| experimental-builtin-metrics = ["dep:google-cloud-monitoring-v3", "dep:opentelemetry", "dep:opentelemetry_sdk"] |
There was a problem hiding this comment.
A thing we learnt the hard way: removing a public feature is a breaking change. You may want to name this _experimental-builtin-metrics because that makes the feature private (by convention) and then removing it is fine.
| wkt = { workspace = true, features = ["time"] } | ||
|
|
||
| # Optional dependencies for built-in metrics | ||
| google-cloud-monitoring-v3 = { workspace = true, optional = true } |
There was a problem hiding this comment.
The new shinny is to use the OpenTelemetry Lightweight Protocol (OTLP). Google Cloud supports the protocol. There are Rust exporters for OTLP, they do lack a connector to inject the auth headers.
Sets up the initial boiler-plate code for adding built-in metrics for Spanner.
The feature is hidden behind a feature flag, meaning that it is currently invisible to customers.