fix(sidekick/rust): Ensure detailed-tracing-attributes flag is fully propagated#2438
Merged
westarle merged 2 commits intogoogleapis:mainfrom Sep 29, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2438 +/- ##
=======================================
Coverage 84.93% 84.93%
=======================================
Files 100 100
Lines 10127 10127
=======================================
Hits 8601 8601
Misses 1185 1185
Partials 341 341 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
046355a to
c9e3965
Compare
…propagated
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.
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.
coryan
requested changes
Sep 29, 2025
Contributor
coryan
left a comment
There was a problem hiding this comment.
You can minimize this change, all the DetailedTracingAttributes: false expectations have no effect, just let them take the default value.
c9e3965 to
42aa4ec
Compare
coryan
approved these changes
Sep 29, 2025
suztomo
pushed a commit
that referenced
this pull request
Oct 13, 2025
Librarian Version: v0.0.0-20251009012716-e267b1dfc9b9 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest <details><summary>librarian: 0.4.0</summary> ## [0.4.0](v0.3.0...v0.4.0) (2025-10-09) ### Features * add `git log` functionality (#2510) ([e267b1d](e267b1d)) * Modify README.md to match our agreed-upon wording (#2503) ([2dc6fc6](2dc6fc6)) * Show actual enum values on setter samples. (#2491) ([13fd5a1](13fd5a1)) * sort library state when writing to `state.yaml` (#2504) ([35e4495](35e4495)) * Generate methods that use server-side streaming (#2474) ([31a496d](31a496d)) * allow configuring tag_format in config.yaml (#2236) ([e0eeddb](e0eeddb)) * `update` supports different roots (#2473) ([65fa7ed](65fa7ed)) * Support git push via SSH (#2397) ([7259194](7259194)) * mount output dir in configure docker command (#2439) ([365019e](365019e)) * Update templates for otel (#2443) ([ea54ba6](ea54ba6)) * support aggregated pagination (#2432) ([5b010b9](5b010b9)) * override pagination items field (#2441) ([4a3664a](4a3664a)) * include source root in configure request (#2431) ([475a62d](475a62d)) * rust+disco bytes (de)serialization (#2428) ([b2a186c](b2a186c)) * enum serialization for non-proto sources (#2410) ([516f29e](516f29e)) * optional singular fields in discovery (#2408) ([c86c2db](c86c2db)) * deprecated elements in discovery docs (#2399) ([1d83853](1d83853)) * allow "." as valid `source_roots` entry (#2396) ([2f52aa7](2f52aa7)) * inline messages in discovery docs (#2394) ([043cf65](043cf65)) * write pr-body.txt to the work root when not pushing (#2395) ([862c7d7](862c7d7)) * define LIBRARIAN_GITHUB_TOKEN as a constant (#2367) ([5979bfd](5979bfd)) ### Bug Fixes * clarify doc and comment with commit and push flag (#2507) ([645e42a](645e42a)) * keep first value for repeated footer keys (#2440) ([e51490d](e51490d)) * group commit msg if they have the same piper id and subject (#2496) ([60b7d38](60b7d38)) * real runs for `rust-publish` (#2484) ([15d63c2](15d63c2)) * Remove unnecessary dereference in transport template (#2481) ([610cec9](610cec9)) * shorten SHAs in generate commit msgs (#2472) ([de336b1](de336b1)) * handle slashes in library IDs (#2463) ([91c0189](91c0189)) * nil check for github.NewClient (#2465) ([71db17e](71db17e)) * Conventional Commit parser filters files based on Librarian flow (#2433) ([6cb55d2](6cb55d2)) * Ensure detailed-tracing-attributes flag is fully propagated (#2438) ([a184f0d](a184f0d)) * relax footer regex to allow line broke footers to be properly recognized (#2388) ([dcbe063](dcbe063)) * release init provides read-only full repository (#2370) ([2e11004](2e11004)) * write the PR body on "commit but no push" (#2430) ([88698b4](88698b4)) * should not push to github when no push flag specified (#2405) ([2a49ae6](2a49ae6)) * only mount global files in configure command (#2377) ([1a2aaa0](1a2aaa0)) * `Map` field attribute in discovery (#2414) ([00c645f](00c645f)) * missing IDs in discovery doc fields (#2386) ([d579dd7](d579dd7)) </details>
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.
This commit fixes the propagation of the
detailed-tracing-attributesflag to all necessary annotation structs and updates the templates to correctly utilize the flag. See #2435 and #2252For googleapis/google-cloud-rust#3239
Specifically:
DetailedTracingAttributesfield tomodelAnnotationsandserviceAnnotationsinannotate.goto make the flag accessible inlib.rs.mustacheand service-level sections oftransport.rs.mustache.annotateModelandannotateServiceto populate the new fields.annotate_test.goto verify theDetailedTracingAttributesflag is correctly set acrossmodelAnnotations,serviceAnnotations,methodAnnotation, andpathBindingAnnotationbased on the codec options.lib.rs.mustacheto initialize the staticINSTRUMENTATION_CLIENT_INFOusingstd::sync::LazyLockto accommodate the non-constdefault()function.transport.rs.mustacheto correctly dereference theLazyLockwhen callingwith_instrumentation(i.e.,&*crate::info::INSTRUMENTATION_CLIENT_INFO).These changes ensure that the conditional code blocks in both
lib.rs.mustacheandtransport.rs.mustacherelated to detailed tracing are generated correctly based on thedetailed-tracing-attributesflag.Tested:
go test -race ./...in the librarian repository to ensure all unit tests pass, including new tests for flag propagation in annotations.google-cloud-showcase-v1beta1client in a localgoogle-cloud-rustclone using the modified librarian:--codec-option=detailed-tracing-attributes=true: - Verifiedsrc/generated/showcase/src/lib.rscontains theINSTRUMENTATION_CLIENT_INFOstatic (usingLazyLock). - Verifiedsrc/generated/showcase/src/transport.rsincludes.with_instrumentation(&*crate::info::INSTRUMENTATION_CLIENT_INFO)calls within theif tracing_is_enabledblocks in thenewmethods. - Confirmed the crate builds and tests pass:cargo build -p google-cloud-showcase-v1beta1cargo test -p google-cloud-showcase-v1beta1detailed-tracing-attributes = "true"insrc/generated/showcase/.sidekick.tomland running refresh without the codec option, confirming the config file is also respected.