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)]
92 pub struct BatchWriteSpans(RequestBuilder<crate::model::BatchWriteSpansRequest>);
93
94 impl BatchWriteSpans {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 pub fn with_request<V: Into<crate::model::BatchWriteSpansRequest>>(mut self, v: V) -> Self {
103 self.0.request = v.into();
104 self
105 }
106
107 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
109 self.0.options = v.into();
110 self
111 }
112
113 pub async fn send(self) -> Result<()> {
115 (*self.0.stub)
116 .batch_write_spans(self.0.request, self.0.options)
117 .await
118 .map(gax::response::Response::into_body)
119 }
120
121 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
125 self.0.request.name = v.into();
126 self
127 }
128
129 pub fn set_spans<T, V>(mut self, v: T) -> Self
133 where
134 T: std::iter::IntoIterator<Item = V>,
135 V: std::convert::Into<crate::model::Span>,
136 {
137 use std::iter::Iterator;
138 self.0.request.spans = v.into_iter().map(|i| i.into()).collect();
139 self
140 }
141 }
142
143 #[doc(hidden)]
144 impl gax::options::internal::RequestBuilder for BatchWriteSpans {
145 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
146 &mut self.0.options
147 }
148 }
149
150 #[derive(Clone, Debug)]
168 pub struct CreateSpan(RequestBuilder<crate::model::Span>);
169
170 impl CreateSpan {
171 pub(crate) fn new(
172 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
173 ) -> Self {
174 Self(RequestBuilder::new(stub))
175 }
176
177 pub fn with_request<V: Into<crate::model::Span>>(mut self, v: V) -> Self {
179 self.0.request = v.into();
180 self
181 }
182
183 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
185 self.0.options = v.into();
186 self
187 }
188
189 pub async fn send(self) -> Result<crate::model::Span> {
191 (*self.0.stub)
192 .create_span(self.0.request, self.0.options)
193 .await
194 .map(gax::response::Response::into_body)
195 }
196
197 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
201 self.0.request.name = v.into();
202 self
203 }
204
205 pub fn set_span_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
209 self.0.request.span_id = v.into();
210 self
211 }
212
213 pub fn set_parent_span_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
215 self.0.request.parent_span_id = v.into();
216 self
217 }
218
219 pub fn set_display_name<T>(mut self, v: T) -> Self
223 where
224 T: std::convert::Into<crate::model::TruncatableString>,
225 {
226 self.0.request.display_name = std::option::Option::Some(v.into());
227 self
228 }
229
230 pub fn set_or_clear_display_name<T>(mut self, v: std::option::Option<T>) -> Self
234 where
235 T: std::convert::Into<crate::model::TruncatableString>,
236 {
237 self.0.request.display_name = v.map(|x| x.into());
238 self
239 }
240
241 pub fn set_start_time<T>(mut self, v: T) -> Self
245 where
246 T: std::convert::Into<wkt::Timestamp>,
247 {
248 self.0.request.start_time = std::option::Option::Some(v.into());
249 self
250 }
251
252 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
256 where
257 T: std::convert::Into<wkt::Timestamp>,
258 {
259 self.0.request.start_time = v.map(|x| x.into());
260 self
261 }
262
263 pub fn set_end_time<T>(mut self, v: T) -> Self
267 where
268 T: std::convert::Into<wkt::Timestamp>,
269 {
270 self.0.request.end_time = std::option::Option::Some(v.into());
271 self
272 }
273
274 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
278 where
279 T: std::convert::Into<wkt::Timestamp>,
280 {
281 self.0.request.end_time = v.map(|x| x.into());
282 self
283 }
284
285 pub fn set_attributes<T>(mut self, v: T) -> Self
287 where
288 T: std::convert::Into<crate::model::span::Attributes>,
289 {
290 self.0.request.attributes = std::option::Option::Some(v.into());
291 self
292 }
293
294 pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
296 where
297 T: std::convert::Into<crate::model::span::Attributes>,
298 {
299 self.0.request.attributes = v.map(|x| x.into());
300 self
301 }
302
303 pub fn set_stack_trace<T>(mut self, v: T) -> Self
305 where
306 T: std::convert::Into<crate::model::StackTrace>,
307 {
308 self.0.request.stack_trace = std::option::Option::Some(v.into());
309 self
310 }
311
312 pub fn set_or_clear_stack_trace<T>(mut self, v: std::option::Option<T>) -> Self
314 where
315 T: std::convert::Into<crate::model::StackTrace>,
316 {
317 self.0.request.stack_trace = v.map(|x| x.into());
318 self
319 }
320
321 pub fn set_time_events<T>(mut self, v: T) -> Self
323 where
324 T: std::convert::Into<crate::model::span::TimeEvents>,
325 {
326 self.0.request.time_events = std::option::Option::Some(v.into());
327 self
328 }
329
330 pub fn set_or_clear_time_events<T>(mut self, v: std::option::Option<T>) -> Self
332 where
333 T: std::convert::Into<crate::model::span::TimeEvents>,
334 {
335 self.0.request.time_events = v.map(|x| x.into());
336 self
337 }
338
339 pub fn set_links<T>(mut self, v: T) -> Self
341 where
342 T: std::convert::Into<crate::model::span::Links>,
343 {
344 self.0.request.links = std::option::Option::Some(v.into());
345 self
346 }
347
348 pub fn set_or_clear_links<T>(mut self, v: std::option::Option<T>) -> Self
350 where
351 T: std::convert::Into<crate::model::span::Links>,
352 {
353 self.0.request.links = v.map(|x| x.into());
354 self
355 }
356
357 pub fn set_status<T>(mut self, v: T) -> Self
359 where
360 T: std::convert::Into<rpc::model::Status>,
361 {
362 self.0.request.status = std::option::Option::Some(v.into());
363 self
364 }
365
366 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
368 where
369 T: std::convert::Into<rpc::model::Status>,
370 {
371 self.0.request.status = v.map(|x| x.into());
372 self
373 }
374
375 pub fn set_same_process_as_parent_span<T>(mut self, v: T) -> Self
377 where
378 T: std::convert::Into<wkt::BoolValue>,
379 {
380 self.0.request.same_process_as_parent_span = std::option::Option::Some(v.into());
381 self
382 }
383
384 pub fn set_or_clear_same_process_as_parent_span<T>(
386 mut self,
387 v: std::option::Option<T>,
388 ) -> Self
389 where
390 T: std::convert::Into<wkt::BoolValue>,
391 {
392 self.0.request.same_process_as_parent_span = v.map(|x| x.into());
393 self
394 }
395
396 pub fn set_child_span_count<T>(mut self, v: T) -> Self
398 where
399 T: std::convert::Into<wkt::Int32Value>,
400 {
401 self.0.request.child_span_count = std::option::Option::Some(v.into());
402 self
403 }
404
405 pub fn set_or_clear_child_span_count<T>(mut self, v: std::option::Option<T>) -> Self
407 where
408 T: std::convert::Into<wkt::Int32Value>,
409 {
410 self.0.request.child_span_count = v.map(|x| x.into());
411 self
412 }
413
414 pub fn set_span_kind<T: Into<crate::model::span::SpanKind>>(mut self, v: T) -> Self {
416 self.0.request.span_kind = v.into();
417 self
418 }
419 }
420
421 #[doc(hidden)]
422 impl gax::options::internal::RequestBuilder for CreateSpan {
423 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
424 &mut self.0.options
425 }
426 }
427}