Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ where T: super::stub::{{Codec.Name}} + std::fmt::Debug + Send + Sync {
pending.await
}
#[cfg(not(google_cloud_unstable_tracing))]
{{/Codec.DetailedTracingAttributes }}
self.inner.{{Codec.Name}}(req, options).await
{{/Codec.DetailedTracingAttributes}}
{{^Codec.DetailedTracingAttributes}}
self.inner.{{Codec.Name}}(req, options).await
{{/Codec.DetailedTracingAttributes}}
}
{{/Codec.Methods}}
{{#Codec.HasLROs}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
{{PathInfo.Codec.IsIdempotent}},
{{/HasAutoPopulatedFields}}
);
let extensions = {
let mut extensions = {
let mut e = Extensions::new();
e.insert(GrpcMethod::new("{{SourceService.Package}}.{{SourceService.Name}}", "{{Name}}"));
e
Expand Down Expand Up @@ -182,11 +182,15 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
Some(String::new())
{{/Codec.ResourceNameTemplateGrpc}}
})();
let attributes = if let Some(rn) = resource_name.filter(|s| !s.is_empty()) {
attributes.set_resource_name(rn)
let attributes = if let Some(rn) = resource_name.as_ref().filter(|s| !s.is_empty()) {
attributes.set_resource_name(rn.clone())
Comment on lines +185 to +186
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
            };

} else {
attributes
};

if let Some(rn) = resource_name {
extensions.insert(gaxi::observability::ResourceName::new(rn));
}
{{/Codec.HasGrpcResourceNameArgs}}
recorder.on_client_request(attributes);
}
Expand Down
Loading