Skip to content

feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates#5298

Closed
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:demo-o11y-template
Closed

feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates#5298
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:demo-o11y-template

Conversation

@haphungw
Copy link
Copy Markdown
Contributor

@haphungw haphungw commented Apr 10, 2026

Update the gRPC client templates to inject ResourceName into tonic::Extensions (or RequestOptions) so that the gRPC tracing middleware can extract it and populate gcp.resource.destination.id in spans.
This ensures that both unary and streaming RPCs correctly propagate the resource name to the transport layer.

@haphungw haphungw changed the title feat(sidekick): inject ResourceName into gRPC request extensions in templates feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates Apr 10, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Rust templates for tracing and gRPC clients. Specifically, it refines the conditional logic for detailed tracing attributes and ensures that resource names are correctly captured in observability extensions within the gRPC transport. A review comment suggests using as_deref() for more idiomatic handling of optional strings.

Comment on lines +185 to +186
let attributes = if let Some(rn) = resource_name.as_ref().filter(|s| !s.is_empty()) {
attributes.set_resource_name(rn.clone())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of as_ref() followed by filter and clone() is slightly redundant here. Since resource_name is an Option<String>, you can directly call filter on it if you own it, or use as_deref() to avoid the explicit clone() if the filter condition allows.

let attributes = if let Some(rn) = resource_name.as_deref().filter(|s| !s.is_empty()) {
                attributes.set_resource_name(rn.to_string())
            } else {
                attributes
            };

@haphungw haphungw changed the title feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates Apr 10, 2026
@haphungw
Copy link
Copy Markdown
Contributor Author

This approach has been replaced by googleapis/google-cloud-rust#5368

@haphungw haphungw closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant