You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(sidekick/rust): Ensure detailed-tracing-attributes flag is fully 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.
0 commit comments