test(storage): staging storage grpc client#3546
Closed
westarle wants to merge 2 commits intogoogleapis:mainfrom
Closed
test(storage): staging storage grpc client#3546westarle wants to merge 2 commits intogoogleapis:mainfrom
westarle wants to merge 2 commits intogoogleapis:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3546 +/- ##
==========================================
- Coverage 95.67% 95.65% -0.03%
==========================================
Files 123 123
Lines 4904 4904
==========================================
- Hits 4692 4691 -1
- Misses 212 213 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a125ea9 to
d8318fe
Compare
westarle
added a commit
to googleapis/librarian
that referenced
this pull request
Oct 17, 2025
This PR introduces feature-gated instrumentation support for gRPC clients generated by Librarian, specifically targeting gRPC-only clients using the `grpc-client` template set. For googleapis/google-cloud-rust#3418 **Changes:** 1. **`internal/sidekick/internal/rust/templates/grpc-client/transport.rs.mustache`:** * Added a `lazy_static` definition for `INSTRUMENTATION_CLIENT_INFO` within the existing `info` module. This static is conditionally compiled based on the `google_cloud_unstable_tracing` cfg flag and the `Codec.DetailedTracingAttributes` Sidekick option. * Modified the `StorageControl::new` function to call `.with_instrumentation()` on the `gaxi::grpc::Client` instance (`inner`). This call is conditional based on `gaxi::options::tracing_enabled(&config)` at runtime, and the entire block is guarded by `{{#Codec.DetailedTracingAttributes}}` and `#[cfg(google_cloud_unstable_tracing)]`. 2. **`internal/sidekick/internal/rust/templates/common/Cargo.toml.mustache`:** * Added `[lints] workspace = true` to ensure generated crates inherit workspace lint configurations, including the `unexpected_cfgs` allowance for `google_cloud_unstable_tracing`. This is also guarded by `{{#Codec.DetailedTracingAttributes}}`. **Testing Steps:** Test PR: googleapis/google-cloud-rust#3546 The following steps were performed to test these template changes, using the `google-cloud-storage` crate's `StorageControl` client as a test case, as it uses the `grpc-client` templates. **Setup:** * Librarian repo on branch `feat/t4-grpc-conditional-instr`. * `google-cloud-rust` repo on branch `feat/t4-grpc-client-with-instr` (which contains the `with_instrumentation` method on `gaxi::grpc::Client`). **Test Case 1: DetailedTracingAttributes ON** 1. **Configure:** Modify `/usr/local/google/home/westarle/src/otel-rust/projects/t4-grpc-network-span/google-cloud-rust/src/storage/src/generated/gapic/.sidekick.toml` to ensure `detailed-tracing-attributes = true`. 2. **Regenerate:** From the Librarian repo root: ```bash go run ./cmd/sidekick refresh -project-root /usr/local/google/home/westarle/src/otel-rust/projects/t4-grpc-network-span/google-cloud-rust -output src/storage/src/generated/gapic ``` 3. **Format:** In the `google-cloud-rust` repo: ```bash cargo fmt -p google-cloud-storage ``` 4. **Verify Diffs:** In the `google-cloud-rust` repo: ```bash git diff src/storage/src/generated/gapic/transport.rs ``` Confirmed that the `INSTRUMENTATION_CLIENT_INFO` static and the call to `inner.with_instrumentation(Some(&info::INSTRUMENTATION_CLIENT_INFO))` were present and correctly guarded. 5. **Test with RUSTFLAGS:** In the `google-cloud-rust` repo: ```bash RUSTFLAGS="--cfg google_cloud_unstable_tracing" cargo test -p google-cloud-storage RUSTFLAGS="--cfg google_cloud_unstable_tracing" cargo clippy -p google-cloud-storage -- -D warnings cargo semver-checks check-release -p google-cloud-storage ``` All checks passed. 6. **Test without RUSTFLAGS:** In the `google-cloud-rust` repo: ```bash cargo test -p google-cloud-storage cargo clippy -p google-cloud-storage -- -D warnings cargo semver-checks check-release -p google-cloud-storage ``` All checks passed. **Test Case 2: DetailedTracingAttributes OFF** 1. **Configure:** Modify `/usr/local/google/home/westarle/src/otel-rust/projects/t4-grpc-network-span/google-cloud-rust/src/storage/src/generated/gapic/.sidekick.toml` to set `detailed-tracing-attributes = false`. 2. **Regenerate:** Repeat step 3 from Test Case 1. 3. **Format:** Repeat step 4 from Test Case 1. 4. **Verify Diffs:** In the `google-cloud-rust` repo: ```bash git diff src/storage/src/generated/gapic/transport.rs ``` Confirmed that the guarded blocks are now absent in `src/storage/src/generated/gapic/transport.rs`. 5. **Test without RUSTFLAGS:** Repeat step 7 from Test Case 1. ```bash cargo test -p google-cloud-storage cargo clippy -p google-cloud-storage -- -D warnings cargo semver-checks check-release -p google-cloud-storage ``` All checks passed. **Cleanup:** * Restored `google-cloud-rust/src/storage/src/generated/gapic/.sidekick.toml` to its original state. These tests confirm that the template changes correctly inject the instrumentation logic only when both the Sidekick option and the compile-time cfg flag are active, and do not affect the build when disabled.
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.
DO NOT MERGE