feat(sidekick): Inject InstrumentationClientInfo for tracing#2252
Merged
westarle merged 3 commits intogoogleapis:mainfrom Sep 24, 2025
Merged
feat(sidekick): Inject InstrumentationClientInfo for tracing#2252westarle merged 3 commits intogoogleapis:mainfrom
westarle merged 3 commits intogoogleapis:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2252 +/- ##
=======================================
Coverage 84.13% 84.13%
=======================================
Files 97 97
Lines 9745 9745
=======================================
Hits 8199 8199
Misses 1199 1199
Partials 347 347 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e88a9fe to
827a186
Compare
coryan
reviewed
Sep 19, 2025
internal/sidekick/internal/rust/templates/crate/src/transport.rs.mustache
Show resolved
Hide resolved
- Add static INSTRUMENTATION_CLIENT_INFO to lib.rs.mustache. - Use INSTRUMENTATION_CLIENT_INFO in transport.rs.mustache unconditionally.
…based on DetailedTracingAttributes\n\nIntegrate the InstrumentationClientInfo and with_instrumentation call within the existing DetailedTracingAttributes feature flag in the templates.
e19aee5 to
9f32a31
Compare
Contributor
Author
|
Updated with feature flag -- tested on and off with showcase. |
coryan
approved these changes
Sep 23, 2025
ldetmer
pushed a commit
that referenced
this pull request
Sep 26, 2025
Librarian Version: v0.0.0-20250925031739-cb21cf1ae8af Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest <details><summary>librarian: 0.3.0</summary> ## [0.3.0](v0.2.0...v0.3.0) (2025-09-25) ### Features * discovery-based APIs and pagination (#2350) ([cb21cf1](cb21cf1)) * Make generated `ProtoMessage` and `ProtoEnum` classes `final` (#2349) ([7d0520b](7d0520b)) * Require that all imports have a version contraints (#2331) Fixes #1989 This should not be landed before googleapis/google-cloud-rust#3396 ([00828d5](00828d5)) * Generate samples for single value setters (#2263) ([f7c0b84](f7c0b84)) * discovery doc arrays (#2337) ([da69195](da69195)) * Inject InstrumentationClientInfo for tracing (#2252) - Add static INSTRUMENTATION_CLIENT_INFO to lib.rs.mustache. - Use INSTRUMENTATION_CLIENT_INFO in transport.rs.mustache if tracing is enabled. For #2212 see also googleapis/google-cloud-rust#3347 and googleapis/google-cloud-rust#3376 ([1358226](1358226)) * parse most object fields (#2318) Parse most fields of object in a discovery doc. Fields with an inline type definition still need some custom work. ([f2d1a10](f2d1a10)) * Add the ability to insert text after the package title (#2323) The current use case for this is to advise users of equivalent Firebase packages. For example: ```toml readme-after-title-text = """> [!TIP] > Flutter applications should use [Firebase AI Logic](https://firebase.google.com/products/firebase-ai-logic). > > The Generate Language API is meant for Dart desktop and cloud applications. > Firebase AI Logic provides client-side access to both the Gemini Developer > API and Vertex AI. """ ``` Which results in a README.md that looks like: <img width="1485" height="909" alt="image" src="https://github.com/user-attachments/assets/a1c9120e-eafd-4394-9562-48c595ab4960" /> ([756e72f](756e72f)) ### Bug Fixes * read version from version.txt file (#2347) Fixes #2348 Moves version.txt to the `internal/cli` package so it can be read by the `embed` package as a variable. When constructing the synthetic version number, use this release version as the base. ([014b5f4](014b5f4)) * race condition in createWorkRoot() (#2338) Creating a temporary directory based on a timestamp is inherently racy. Use the standard functions to create temporary directories, and relax the tests to check for what matters. ([46428ca](46428ca)) * parse github remote from local directory (#2328) Fixes #2327 ([1c71bd9](1c71bd9)) </details>
This was referenced Sep 29, 2025
westarle
added a commit
that referenced
this pull request
Sep 29, 2025
…propagated (#2438) This commit fixes the propagation of the `detailed-tracing-attributes` flag to all necessary annotation structs and updates the templates to correctly utilize the flag. See #2435 and #2252 For googleapis/google-cloud-rust#3239 Specifically: - Adds `DetailedTracingAttributes` field to `modelAnnotations` and `serviceAnnotations` in `annotate.go` to make the flag accessible in `lib.rs.mustache` and service-level sections of `transport.rs.mustache`. - Updates `annotateModel` and `annotateService` to populate the new fields. - Adds comprehensive unit tests in `annotate_test.go` to verify the `DetailedTracingAttributes` flag is correctly set across `modelAnnotations`, `serviceAnnotations`, `methodAnnotation`, and `pathBindingAnnotation` based on the codec options. - Modifies `lib.rs.mustache` to initialize the static `INSTRUMENTATION_CLIENT_INFO` using `std::sync::LazyLock` to accommodate the non-const `default()` function. - Updates `transport.rs.mustache` to correctly dereference the `LazyLock` when calling `with_instrumentation` (i.e., `&*crate::info::INSTRUMENTATION_CLIENT_INFO`). These changes ensure that the conditional code blocks in both `lib.rs.mustache` and `transport.rs.mustache` related to detailed tracing are generated correctly based on the `detailed-tracing-attributes` flag. Tested: - Ran `go test -race ./...` in the librarian repository to ensure all unit tests pass, including new tests for flag propagation in annotations. - Manually regenerated the `google-cloud-showcase-v1beta1` client in a local `google-cloud-rust` clone using the modified librarian: 1. With `--codec-option=detailed-tracing-attributes=true`: - Verified `src/generated/showcase/src/lib.rs` contains the `INSTRUMENTATION_CLIENT_INFO` static (using `LazyLock`). - Verified `src/generated/showcase/src/transport.rs` includes `.with_instrumentation(&*crate::info::INSTRUMENTATION_CLIENT_INFO)` calls within the `if tracing_is_enabled` blocks in the `new` methods. - Confirmed the crate builds and tests pass: `cargo build -p google-cloud-showcase-v1beta1` `cargo test -p google-cloud-showcase-v1beta1` 2. With the flag off (default): - Verified the above tracing-specific code is absent. 3. By setting `detailed-tracing-attributes = "true"` in `src/generated/showcase/.sidekick.toml` and running refresh without the codec option, confirming the config file is also respected.
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.
For #2212 see also googleapis/google-cloud-rust#3347 and googleapis/google-cloud-rust#3376