feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates#5298
feat(sidekick/rust): inject ResourceName into gRPC request extensions in templates#5298haphungw wants to merge 1 commit into
ResourceName into gRPC request extensions in templates#5298Conversation
There was a problem hiding this comment.
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.
| let attributes = if let Some(rn) = resource_name.as_ref().filter(|s| !s.is_empty()) { | ||
| attributes.set_resource_name(rn.clone()) |
There was a problem hiding this comment.
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
};
ResourceName into gRPC request extensions in templates
|
This approach has been replaced by googleapis/google-cloud-rust#5368 |
Update the gRPC client templates to inject
ResourceNameintotonic::Extensions(orRequestOptions) so that the gRPC tracing middleware can extract it and populategcp.resource.destination.idin spans.This ensures that both unary and streaming RPCs correctly propagate the resource name to the transport layer.