Skip to content

test(storage): staging storage grpc client#3546

Closed
westarle wants to merge 2 commits intogoogleapis:mainfrom
westarle:test/librarian-pr2
Closed

test(storage): staging storage grpc client#3546
westarle wants to merge 2 commits intogoogleapis:mainfrom
westarle:test/librarian-pr2

Conversation

@westarle
Copy link
Copy Markdown
Contributor

DO NOT MERGE

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Oct 16, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.65%. Comparing base (646566a) to head (d8318fe).
⚠️ Report is 15 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@westarle westarle closed this Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant