google_cloud_trace_v2/
builder.rs1pub mod trace_service {
18 use crate::Result;
19
20 pub type ClientBuilder =
34 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::TraceService;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = TraceService;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> gax::client_builder::Result<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
55 request: R,
56 options: gax::options::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: gax::options::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[derive(Clone, Debug)]
91 pub struct BatchWriteSpans(RequestBuilder<crate::model::BatchWriteSpansRequest>);
92
93 impl BatchWriteSpans {
94 pub(crate) fn new(
95 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
96 ) -> Self {
97 Self(RequestBuilder::new(stub))
98 }
99
100 pub fn with_request<V: Into<crate::model::BatchWriteSpansRequest>>(mut self, v: V) -> Self {
102 self.0.request = v.into();
103 self
104 }
105
106 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
108 self.0.options = v.into();
109 self
110 }
111
112 pub async fn send(self) -> Result<()> {
114 (*self.0.stub)
115 .batch_write_spans(self.0.request, self.0.options)
116 .await
117 .map(gax::response::Response::into_body)
118 }
119
120 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
124 self.0.request.name = v.into();
125 self
126 }
127
128 pub fn set_spans<T, V>(mut self, v: T) -> Self
132 where
133 T: std::iter::IntoIterator<Item = V>,
134 V: std::convert::Into<crate::model::Span>,
135 {
136 use std::iter::Iterator;
137 self.0.request.spans = v.into_iter().map(|i| i.into()).collect();
138 self
139 }
140 }
141
142 #[doc(hidden)]
143 impl gax::options::internal::RequestBuilder for BatchWriteSpans {
144 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
145 &mut self.0.options
146 }
147 }
148
149 #[derive(Clone, Debug)]
166 pub struct CreateSpan(RequestBuilder<crate::model::Span>);
167
168 impl CreateSpan {
169 pub(crate) fn new(
170 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
171 ) -> Self {
172 Self(RequestBuilder::new(stub))
173 }
174
175 pub fn with_request<V: Into<crate::model::Span>>(mut self, v: V) -> Self {
177 self.0.request = v.into();
178 self
179 }
180
181 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
183 self.0.options = v.into();
184 self
185 }
186
187 pub async fn send(self) -> Result<crate::model::Span> {
189 (*self.0.stub)
190 .create_span(self.0.request, self.0.options)
191 .await
192 .map(gax::response::Response::into_body)
193 }
194
195 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
199 self.0.request.name = v.into();
200 self
201 }
202
203 pub fn set_span_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
207 self.0.request.span_id = v.into();
208 self
209 }
210
211 pub fn set_parent_span_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
213 self.0.request.parent_span_id = v.into();
214 self
215 }
216
217 pub fn set_display_name<T>(mut self, v: T) -> Self
221 where
222 T: std::convert::Into<crate::model::TruncatableString>,
223 {
224 self.0.request.display_name = std::option::Option::Some(v.into());
225 self
226 }
227
228 pub fn set_or_clear_display_name<T>(mut self, v: std::option::Option<T>) -> Self
232 where
233 T: std::convert::Into<crate::model::TruncatableString>,
234 {
235 self.0.request.display_name = v.map(|x| x.into());
236 self
237 }
238
239 pub fn set_start_time<T>(mut self, v: T) -> Self
243 where
244 T: std::convert::Into<wkt::Timestamp>,
245 {
246 self.0.request.start_time = std::option::Option::Some(v.into());
247 self
248 }
249
250 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
254 where
255 T: std::convert::Into<wkt::Timestamp>,
256 {
257 self.0.request.start_time = v.map(|x| x.into());
258 self
259 }
260
261 pub fn set_end_time<T>(mut self, v: T) -> Self
265 where
266 T: std::convert::Into<wkt::Timestamp>,
267 {
268 self.0.request.end_time = std::option::Option::Some(v.into());
269 self
270 }
271
272 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
276 where
277 T: std::convert::Into<wkt::Timestamp>,
278 {
279 self.0.request.end_time = v.map(|x| x.into());
280 self
281 }
282
283 pub fn set_attributes<T>(mut self, v: T) -> Self
285 where
286 T: std::convert::Into<crate::model::span::Attributes>,
287 {
288 self.0.request.attributes = std::option::Option::Some(v.into());
289 self
290 }
291
292 pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
294 where
295 T: std::convert::Into<crate::model::span::Attributes>,
296 {
297 self.0.request.attributes = v.map(|x| x.into());
298 self
299 }
300
301 pub fn set_stack_trace<T>(mut self, v: T) -> Self
303 where
304 T: std::convert::Into<crate::model::StackTrace>,
305 {
306 self.0.request.stack_trace = std::option::Option::Some(v.into());
307 self
308 }
309
310 pub fn set_or_clear_stack_trace<T>(mut self, v: std::option::Option<T>) -> Self
312 where
313 T: std::convert::Into<crate::model::StackTrace>,
314 {
315 self.0.request.stack_trace = v.map(|x| x.into());
316 self
317 }
318
319 pub fn set_time_events<T>(mut self, v: T) -> Self
321 where
322 T: std::convert::Into<crate::model::span::TimeEvents>,
323 {
324 self.0.request.time_events = std::option::Option::Some(v.into());
325 self
326 }
327
328 pub fn set_or_clear_time_events<T>(mut self, v: std::option::Option<T>) -> Self
330 where
331 T: std::convert::Into<crate::model::span::TimeEvents>,
332 {
333 self.0.request.time_events = v.map(|x| x.into());
334 self
335 }
336
337 pub fn set_links<T>(mut self, v: T) -> Self
339 where
340 T: std::convert::Into<crate::model::span::Links>,
341 {
342 self.0.request.links = std::option::Option::Some(v.into());
343 self
344 }
345
346 pub fn set_or_clear_links<T>(mut self, v: std::option::Option<T>) -> Self
348 where
349 T: std::convert::Into<crate::model::span::Links>,
350 {
351 self.0.request.links = v.map(|x| x.into());
352 self
353 }
354
355 pub fn set_status<T>(mut self, v: T) -> Self
357 where
358 T: std::convert::Into<rpc::model::Status>,
359 {
360 self.0.request.status = std::option::Option::Some(v.into());
361 self
362 }
363
364 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
366 where
367 T: std::convert::Into<rpc::model::Status>,
368 {
369 self.0.request.status = v.map(|x| x.into());
370 self
371 }
372
373 pub fn set_same_process_as_parent_span<T>(mut self, v: T) -> Self
375 where
376 T: std::convert::Into<wkt::BoolValue>,
377 {
378 self.0.request.same_process_as_parent_span = std::option::Option::Some(v.into());
379 self
380 }
381
382 pub fn set_or_clear_same_process_as_parent_span<T>(
384 mut self,
385 v: std::option::Option<T>,
386 ) -> Self
387 where
388 T: std::convert::Into<wkt::BoolValue>,
389 {
390 self.0.request.same_process_as_parent_span = v.map(|x| x.into());
391 self
392 }
393
394 pub fn set_child_span_count<T>(mut self, v: T) -> Self
396 where
397 T: std::convert::Into<wkt::Int32Value>,
398 {
399 self.0.request.child_span_count = std::option::Option::Some(v.into());
400 self
401 }
402
403 pub fn set_or_clear_child_span_count<T>(mut self, v: std::option::Option<T>) -> Self
405 where
406 T: std::convert::Into<wkt::Int32Value>,
407 {
408 self.0.request.child_span_count = v.map(|x| x.into());
409 self
410 }
411
412 pub fn set_span_kind<T: Into<crate::model::span::SpanKind>>(mut self, v: T) -> Self {
414 self.0.request.span_kind = v.into();
415 self
416 }
417 }
418
419 #[doc(hidden)]
420 impl gax::options::internal::RequestBuilder for CreateSpan {
421 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
422 &mut self.0.options
423 }
424 }
425}