Skip to content

Commit 13bef19

Browse files
authored
feat(rust): Set url.template in RequestOptions (#2248)
Modifies the transport.rs.mustache template to call google_cloud_gax::options::internal::set_path_template() for each binding. This provides the url.template attribute for OpenTelemetry spans. See #2212 and googleapis/google-cloud-rust#3346 and googleapis/google-cloud-rust#3368 Tested with #2247
1 parent 4d3c118 commit 13bef19

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/sidekick/internal/rust/templates/crate/src/transport.rs.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
8080
true,
8181
);
8282
{{/HasAutoPopulatedFields}}
83-
let (builder, method) = None
83+
let (builder, method, path_template) = None
8484
{{#PathInfo.Bindings}}
8585
.or_else(|| {
8686
{{#Codec.HasVariablePath}}
@@ -94,6 +94,7 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
9494
{{^Codec.HasVariablePath}}
9595
let path = "{{Codec.PathFmt}}".to_string();
9696
{{/Codec.HasVariablePath}}
97+
let path_template = "{{Codec.PathTemplate}}";
9798
9899
let builder = self
99100
.inner
@@ -112,7 +113,7 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
112113
{{/Codec.QueryParams}}
113114
let builder = Ok(builder);
114115
{{/Codec.QueryParamsCanFail}}
115-
Some(builder.map(|b| (b, reqwest::Method::{{Verb}})))
116+
Some(builder.map(|b| (b, reqwest::Method::{{Verb}}, path_template)))
116117
})
117118
{{/PathInfo.Bindings}}
118119
.ok_or_else(|| {
@@ -132,6 +133,7 @@ impl super::stub::{{Codec.Name}} for {{Codec.Name}} {
132133
{{/PathInfo.Bindings}}
133134
gax::error::Error::binding(BindingError { paths })
134135
})??;
136+
let options = gax::options::internal::set_path_template(options, path_template);
135137
let options = gax::options::internal::set_default_idempotency(
136138
options,
137139
{{! TODO(#2588) - return idempotency from the above closure }}

0 commit comments

Comments
 (0)