google_cloud_trace_v2/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_rpc;
25extern crate serde;
26extern crate serde_json;
27extern crate serde_with;
28extern crate std;
29extern crate tracing;
30extern crate wkt;
31
32mod debug;
33mod deserialize;
34mod serialize;
35
36/// A span represents a single operation within a trace. Spans can be
37/// nested to form a trace tree. Often, a trace contains a root span
38/// that describes the end-to-end latency, and one or more subspans for
39/// its sub-operations.
40///
41/// A trace can also contain multiple root spans, or none at all.
42/// Spans do not need to be contiguous. There might be
43/// gaps or overlaps between spans in a trace.
44#[derive(Clone, Default, PartialEq)]
45#[non_exhaustive]
46pub struct Span {
47 /// Required. The resource name of the span in the following format:
48 ///
49 /// * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]`
50 ///
51 /// `[TRACE_ID]` is a unique identifier for a trace within a project;
52 /// it is a 32-character hexadecimal encoding of a 16-byte array. It should
53 /// not be zero.
54 ///
55 /// `[SPAN_ID]` is a unique identifier for a span within a trace; it
56 /// is a 16-character hexadecimal encoding of an 8-byte array. It should not
57 /// be zero.
58 /// .
59 pub name: std::string::String,
60
61 /// Required. The `[SPAN_ID]` portion of the span's resource name.
62 pub span_id: std::string::String,
63
64 /// The `[SPAN_ID]` of this span's parent span. If this is a root span,
65 /// then this field must be empty.
66 pub parent_span_id: std::string::String,
67
68 /// Required. A description of the span's operation (up to 128 bytes).
69 /// Cloud Trace displays the description in the
70 /// Cloud console.
71 /// For example, the display name can be a qualified method name or a file name
72 /// and a line number where the operation is called. A best practice is to use
73 /// the same display name within an application and at the same call point.
74 /// This makes it easier to correlate spans in different traces.
75 pub display_name: std::option::Option<crate::model::TruncatableString>,
76
77 /// Required. The start time of the span. On the client side, this is the time
78 /// kept by the local machine where the span execution starts. On the server
79 /// side, this is the time when the server's application handler starts
80 /// running.
81 pub start_time: std::option::Option<wkt::Timestamp>,
82
83 /// Required. The end time of the span. On the client side, this is the time
84 /// kept by the local machine where the span execution ends. On the server
85 /// side, this is the time when the server application handler stops running.
86 pub end_time: std::option::Option<wkt::Timestamp>,
87
88 /// A set of attributes on the span. You can have up to 32 attributes per
89 /// span.
90 pub attributes: std::option::Option<crate::model::span::Attributes>,
91
92 /// Stack trace captured at the start of the span.
93 pub stack_trace: std::option::Option<crate::model::StackTrace>,
94
95 /// A set of time events. You can have up to 32 annotations and 128 message
96 /// events per span.
97 pub time_events: std::option::Option<crate::model::span::TimeEvents>,
98
99 /// Links associated with the span. You can have up to 128 links per Span.
100 pub links: std::option::Option<crate::model::span::Links>,
101
102 /// Optional. The final status for this span.
103 pub status: std::option::Option<google_cloud_rpc::model::Status>,
104
105 /// Optional. Set this parameter to indicate whether this span is in
106 /// the same process as its parent. If you do not set this parameter,
107 /// Trace is unable to take advantage of this helpful information.
108 pub same_process_as_parent_span: std::option::Option<wkt::BoolValue>,
109
110 /// Optional. The number of child spans that were generated while this span
111 /// was active. If set, allows implementation to detect missing child spans.
112 pub child_span_count: std::option::Option<wkt::Int32Value>,
113
114 /// Optional. Distinguishes between spans generated in a particular context.
115 /// For example, two spans with the same name may be distinguished using
116 /// `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
117 pub span_kind: crate::model::span::SpanKind,
118
119 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
120}
121
122impl Span {
123 pub fn new() -> Self {
124 std::default::Default::default()
125 }
126
127 /// Sets the value of [name][crate::model::Span::name].
128 ///
129 /// # Example
130 /// ```ignore,no_run
131 /// # use google_cloud_trace_v2::model::Span;
132 /// let x = Span::new().set_name("example");
133 /// ```
134 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
135 self.name = v.into();
136 self
137 }
138
139 /// Sets the value of [span_id][crate::model::Span::span_id].
140 ///
141 /// # Example
142 /// ```ignore,no_run
143 /// # use google_cloud_trace_v2::model::Span;
144 /// let x = Span::new().set_span_id("example");
145 /// ```
146 pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
147 self.span_id = v.into();
148 self
149 }
150
151 /// Sets the value of [parent_span_id][crate::model::Span::parent_span_id].
152 ///
153 /// # Example
154 /// ```ignore,no_run
155 /// # use google_cloud_trace_v2::model::Span;
156 /// let x = Span::new().set_parent_span_id("example");
157 /// ```
158 pub fn set_parent_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
159 self.parent_span_id = v.into();
160 self
161 }
162
163 /// Sets the value of [display_name][crate::model::Span::display_name].
164 ///
165 /// # Example
166 /// ```ignore,no_run
167 /// # use google_cloud_trace_v2::model::Span;
168 /// use google_cloud_trace_v2::model::TruncatableString;
169 /// let x = Span::new().set_display_name(TruncatableString::default()/* use setters */);
170 /// ```
171 pub fn set_display_name<T>(mut self, v: T) -> Self
172 where
173 T: std::convert::Into<crate::model::TruncatableString>,
174 {
175 self.display_name = std::option::Option::Some(v.into());
176 self
177 }
178
179 /// Sets or clears the value of [display_name][crate::model::Span::display_name].
180 ///
181 /// # Example
182 /// ```ignore,no_run
183 /// # use google_cloud_trace_v2::model::Span;
184 /// use google_cloud_trace_v2::model::TruncatableString;
185 /// let x = Span::new().set_or_clear_display_name(Some(TruncatableString::default()/* use setters */));
186 /// let x = Span::new().set_or_clear_display_name(None::<TruncatableString>);
187 /// ```
188 pub fn set_or_clear_display_name<T>(mut self, v: std::option::Option<T>) -> Self
189 where
190 T: std::convert::Into<crate::model::TruncatableString>,
191 {
192 self.display_name = v.map(|x| x.into());
193 self
194 }
195
196 /// Sets the value of [start_time][crate::model::Span::start_time].
197 ///
198 /// # Example
199 /// ```ignore,no_run
200 /// # use google_cloud_trace_v2::model::Span;
201 /// use wkt::Timestamp;
202 /// let x = Span::new().set_start_time(Timestamp::default()/* use setters */);
203 /// ```
204 pub fn set_start_time<T>(mut self, v: T) -> Self
205 where
206 T: std::convert::Into<wkt::Timestamp>,
207 {
208 self.start_time = std::option::Option::Some(v.into());
209 self
210 }
211
212 /// Sets or clears the value of [start_time][crate::model::Span::start_time].
213 ///
214 /// # Example
215 /// ```ignore,no_run
216 /// # use google_cloud_trace_v2::model::Span;
217 /// use wkt::Timestamp;
218 /// let x = Span::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
219 /// let x = Span::new().set_or_clear_start_time(None::<Timestamp>);
220 /// ```
221 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
222 where
223 T: std::convert::Into<wkt::Timestamp>,
224 {
225 self.start_time = v.map(|x| x.into());
226 self
227 }
228
229 /// Sets the value of [end_time][crate::model::Span::end_time].
230 ///
231 /// # Example
232 /// ```ignore,no_run
233 /// # use google_cloud_trace_v2::model::Span;
234 /// use wkt::Timestamp;
235 /// let x = Span::new().set_end_time(Timestamp::default()/* use setters */);
236 /// ```
237 pub fn set_end_time<T>(mut self, v: T) -> Self
238 where
239 T: std::convert::Into<wkt::Timestamp>,
240 {
241 self.end_time = std::option::Option::Some(v.into());
242 self
243 }
244
245 /// Sets or clears the value of [end_time][crate::model::Span::end_time].
246 ///
247 /// # Example
248 /// ```ignore,no_run
249 /// # use google_cloud_trace_v2::model::Span;
250 /// use wkt::Timestamp;
251 /// let x = Span::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
252 /// let x = Span::new().set_or_clear_end_time(None::<Timestamp>);
253 /// ```
254 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
255 where
256 T: std::convert::Into<wkt::Timestamp>,
257 {
258 self.end_time = v.map(|x| x.into());
259 self
260 }
261
262 /// Sets the value of [attributes][crate::model::Span::attributes].
263 ///
264 /// # Example
265 /// ```ignore,no_run
266 /// # use google_cloud_trace_v2::model::Span;
267 /// use google_cloud_trace_v2::model::span::Attributes;
268 /// let x = Span::new().set_attributes(Attributes::default()/* use setters */);
269 /// ```
270 pub fn set_attributes<T>(mut self, v: T) -> Self
271 where
272 T: std::convert::Into<crate::model::span::Attributes>,
273 {
274 self.attributes = std::option::Option::Some(v.into());
275 self
276 }
277
278 /// Sets or clears the value of [attributes][crate::model::Span::attributes].
279 ///
280 /// # Example
281 /// ```ignore,no_run
282 /// # use google_cloud_trace_v2::model::Span;
283 /// use google_cloud_trace_v2::model::span::Attributes;
284 /// let x = Span::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
285 /// let x = Span::new().set_or_clear_attributes(None::<Attributes>);
286 /// ```
287 pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
288 where
289 T: std::convert::Into<crate::model::span::Attributes>,
290 {
291 self.attributes = v.map(|x| x.into());
292 self
293 }
294
295 /// Sets the value of [stack_trace][crate::model::Span::stack_trace].
296 ///
297 /// # Example
298 /// ```ignore,no_run
299 /// # use google_cloud_trace_v2::model::Span;
300 /// use google_cloud_trace_v2::model::StackTrace;
301 /// let x = Span::new().set_stack_trace(StackTrace::default()/* use setters */);
302 /// ```
303 pub fn set_stack_trace<T>(mut self, v: T) -> Self
304 where
305 T: std::convert::Into<crate::model::StackTrace>,
306 {
307 self.stack_trace = std::option::Option::Some(v.into());
308 self
309 }
310
311 /// Sets or clears the value of [stack_trace][crate::model::Span::stack_trace].
312 ///
313 /// # Example
314 /// ```ignore,no_run
315 /// # use google_cloud_trace_v2::model::Span;
316 /// use google_cloud_trace_v2::model::StackTrace;
317 /// let x = Span::new().set_or_clear_stack_trace(Some(StackTrace::default()/* use setters */));
318 /// let x = Span::new().set_or_clear_stack_trace(None::<StackTrace>);
319 /// ```
320 pub fn set_or_clear_stack_trace<T>(mut self, v: std::option::Option<T>) -> Self
321 where
322 T: std::convert::Into<crate::model::StackTrace>,
323 {
324 self.stack_trace = v.map(|x| x.into());
325 self
326 }
327
328 /// Sets the value of [time_events][crate::model::Span::time_events].
329 ///
330 /// # Example
331 /// ```ignore,no_run
332 /// # use google_cloud_trace_v2::model::Span;
333 /// use google_cloud_trace_v2::model::span::TimeEvents;
334 /// let x = Span::new().set_time_events(TimeEvents::default()/* use setters */);
335 /// ```
336 pub fn set_time_events<T>(mut self, v: T) -> Self
337 where
338 T: std::convert::Into<crate::model::span::TimeEvents>,
339 {
340 self.time_events = std::option::Option::Some(v.into());
341 self
342 }
343
344 /// Sets or clears the value of [time_events][crate::model::Span::time_events].
345 ///
346 /// # Example
347 /// ```ignore,no_run
348 /// # use google_cloud_trace_v2::model::Span;
349 /// use google_cloud_trace_v2::model::span::TimeEvents;
350 /// let x = Span::new().set_or_clear_time_events(Some(TimeEvents::default()/* use setters */));
351 /// let x = Span::new().set_or_clear_time_events(None::<TimeEvents>);
352 /// ```
353 pub fn set_or_clear_time_events<T>(mut self, v: std::option::Option<T>) -> Self
354 where
355 T: std::convert::Into<crate::model::span::TimeEvents>,
356 {
357 self.time_events = v.map(|x| x.into());
358 self
359 }
360
361 /// Sets the value of [links][crate::model::Span::links].
362 ///
363 /// # Example
364 /// ```ignore,no_run
365 /// # use google_cloud_trace_v2::model::Span;
366 /// use google_cloud_trace_v2::model::span::Links;
367 /// let x = Span::new().set_links(Links::default()/* use setters */);
368 /// ```
369 pub fn set_links<T>(mut self, v: T) -> Self
370 where
371 T: std::convert::Into<crate::model::span::Links>,
372 {
373 self.links = std::option::Option::Some(v.into());
374 self
375 }
376
377 /// Sets or clears the value of [links][crate::model::Span::links].
378 ///
379 /// # Example
380 /// ```ignore,no_run
381 /// # use google_cloud_trace_v2::model::Span;
382 /// use google_cloud_trace_v2::model::span::Links;
383 /// let x = Span::new().set_or_clear_links(Some(Links::default()/* use setters */));
384 /// let x = Span::new().set_or_clear_links(None::<Links>);
385 /// ```
386 pub fn set_or_clear_links<T>(mut self, v: std::option::Option<T>) -> Self
387 where
388 T: std::convert::Into<crate::model::span::Links>,
389 {
390 self.links = v.map(|x| x.into());
391 self
392 }
393
394 /// Sets the value of [status][crate::model::Span::status].
395 ///
396 /// # Example
397 /// ```ignore,no_run
398 /// # use google_cloud_trace_v2::model::Span;
399 /// use google_cloud_rpc::model::Status;
400 /// let x = Span::new().set_status(Status::default()/* use setters */);
401 /// ```
402 pub fn set_status<T>(mut self, v: T) -> Self
403 where
404 T: std::convert::Into<google_cloud_rpc::model::Status>,
405 {
406 self.status = std::option::Option::Some(v.into());
407 self
408 }
409
410 /// Sets or clears the value of [status][crate::model::Span::status].
411 ///
412 /// # Example
413 /// ```ignore,no_run
414 /// # use google_cloud_trace_v2::model::Span;
415 /// use google_cloud_rpc::model::Status;
416 /// let x = Span::new().set_or_clear_status(Some(Status::default()/* use setters */));
417 /// let x = Span::new().set_or_clear_status(None::<Status>);
418 /// ```
419 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
420 where
421 T: std::convert::Into<google_cloud_rpc::model::Status>,
422 {
423 self.status = v.map(|x| x.into());
424 self
425 }
426
427 /// Sets the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
428 ///
429 /// # Example
430 /// ```ignore,no_run
431 /// # use google_cloud_trace_v2::model::Span;
432 /// use wkt::BoolValue;
433 /// let x = Span::new().set_same_process_as_parent_span(BoolValue::default()/* use setters */);
434 /// ```
435 pub fn set_same_process_as_parent_span<T>(mut self, v: T) -> Self
436 where
437 T: std::convert::Into<wkt::BoolValue>,
438 {
439 self.same_process_as_parent_span = std::option::Option::Some(v.into());
440 self
441 }
442
443 /// Sets or clears the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
444 ///
445 /// # Example
446 /// ```ignore,no_run
447 /// # use google_cloud_trace_v2::model::Span;
448 /// use wkt::BoolValue;
449 /// let x = Span::new().set_or_clear_same_process_as_parent_span(Some(BoolValue::default()/* use setters */));
450 /// let x = Span::new().set_or_clear_same_process_as_parent_span(None::<BoolValue>);
451 /// ```
452 pub fn set_or_clear_same_process_as_parent_span<T>(mut self, v: std::option::Option<T>) -> Self
453 where
454 T: std::convert::Into<wkt::BoolValue>,
455 {
456 self.same_process_as_parent_span = v.map(|x| x.into());
457 self
458 }
459
460 /// Sets the value of [child_span_count][crate::model::Span::child_span_count].
461 ///
462 /// # Example
463 /// ```ignore,no_run
464 /// # use google_cloud_trace_v2::model::Span;
465 /// use wkt::Int32Value;
466 /// let x = Span::new().set_child_span_count(Int32Value::default()/* use setters */);
467 /// ```
468 pub fn set_child_span_count<T>(mut self, v: T) -> Self
469 where
470 T: std::convert::Into<wkt::Int32Value>,
471 {
472 self.child_span_count = std::option::Option::Some(v.into());
473 self
474 }
475
476 /// Sets or clears the value of [child_span_count][crate::model::Span::child_span_count].
477 ///
478 /// # Example
479 /// ```ignore,no_run
480 /// # use google_cloud_trace_v2::model::Span;
481 /// use wkt::Int32Value;
482 /// let x = Span::new().set_or_clear_child_span_count(Some(Int32Value::default()/* use setters */));
483 /// let x = Span::new().set_or_clear_child_span_count(None::<Int32Value>);
484 /// ```
485 pub fn set_or_clear_child_span_count<T>(mut self, v: std::option::Option<T>) -> Self
486 where
487 T: std::convert::Into<wkt::Int32Value>,
488 {
489 self.child_span_count = v.map(|x| x.into());
490 self
491 }
492
493 /// Sets the value of [span_kind][crate::model::Span::span_kind].
494 ///
495 /// # Example
496 /// ```ignore,no_run
497 /// # use google_cloud_trace_v2::model::Span;
498 /// use google_cloud_trace_v2::model::span::SpanKind;
499 /// let x0 = Span::new().set_span_kind(SpanKind::Internal);
500 /// let x1 = Span::new().set_span_kind(SpanKind::Server);
501 /// let x2 = Span::new().set_span_kind(SpanKind::Client);
502 /// ```
503 pub fn set_span_kind<T: std::convert::Into<crate::model::span::SpanKind>>(
504 mut self,
505 v: T,
506 ) -> Self {
507 self.span_kind = v.into();
508 self
509 }
510}
511
512impl wkt::message::Message for Span {
513 fn typename() -> &'static str {
514 "type.googleapis.com/google.devtools.cloudtrace.v2.Span"
515 }
516}
517
518/// Defines additional types related to [Span].
519pub mod span {
520 #[allow(unused_imports)]
521 use super::*;
522
523 /// A set of attributes as key-value pairs.
524 #[derive(Clone, Default, PartialEq)]
525 #[non_exhaustive]
526 pub struct Attributes {
527 /// A set of attributes. Each attribute's key can be up to 128 bytes
528 /// long. The value can be a string up to 256 bytes, a signed 64-bit integer,
529 /// or the boolean values `true` or `false`. For example:
530 ///
531 /// ```norust
532 /// "/instance_id": { "string_value": { "value": "my-instance" } }
533 /// "/http/request_bytes": { "int_value": 300 }
534 /// "abc.com/myattribute": { "bool_value": false }
535 /// ```
536 pub attribute_map:
537 std::collections::HashMap<std::string::String, crate::model::AttributeValue>,
538
539 /// The number of attributes that were discarded. Attributes can be discarded
540 /// because their keys are too long or because there are too many attributes.
541 /// If this value is 0 then all attributes are valid.
542 pub dropped_attributes_count: i32,
543
544 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
545 }
546
547 impl Attributes {
548 pub fn new() -> Self {
549 std::default::Default::default()
550 }
551
552 /// Sets the value of [attribute_map][crate::model::span::Attributes::attribute_map].
553 ///
554 /// # Example
555 /// ```ignore,no_run
556 /// # use google_cloud_trace_v2::model::span::Attributes;
557 /// use google_cloud_trace_v2::model::AttributeValue;
558 /// let x = Attributes::new().set_attribute_map([
559 /// ("key0", AttributeValue::default()/* use setters */),
560 /// ("key1", AttributeValue::default()/* use (different) setters */),
561 /// ]);
562 /// ```
563 pub fn set_attribute_map<T, K, V>(mut self, v: T) -> Self
564 where
565 T: std::iter::IntoIterator<Item = (K, V)>,
566 K: std::convert::Into<std::string::String>,
567 V: std::convert::Into<crate::model::AttributeValue>,
568 {
569 use std::iter::Iterator;
570 self.attribute_map = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
571 self
572 }
573
574 /// Sets the value of [dropped_attributes_count][crate::model::span::Attributes::dropped_attributes_count].
575 ///
576 /// # Example
577 /// ```ignore,no_run
578 /// # use google_cloud_trace_v2::model::span::Attributes;
579 /// let x = Attributes::new().set_dropped_attributes_count(42);
580 /// ```
581 pub fn set_dropped_attributes_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
582 self.dropped_attributes_count = v.into();
583 self
584 }
585 }
586
587 impl wkt::message::Message for Attributes {
588 fn typename() -> &'static str {
589 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Attributes"
590 }
591 }
592
593 /// A time-stamped annotation or message event in the Span.
594 #[derive(Clone, Default, PartialEq)]
595 #[non_exhaustive]
596 pub struct TimeEvent {
597 /// The timestamp indicating the time the event occurred.
598 pub time: std::option::Option<wkt::Timestamp>,
599
600 /// A `TimeEvent` can contain either an `Annotation` object or a
601 /// `MessageEvent` object, but not both.
602 pub value: std::option::Option<crate::model::span::time_event::Value>,
603
604 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
605 }
606
607 impl TimeEvent {
608 pub fn new() -> Self {
609 std::default::Default::default()
610 }
611
612 /// Sets the value of [time][crate::model::span::TimeEvent::time].
613 ///
614 /// # Example
615 /// ```ignore,no_run
616 /// # use google_cloud_trace_v2::model::span::TimeEvent;
617 /// use wkt::Timestamp;
618 /// let x = TimeEvent::new().set_time(Timestamp::default()/* use setters */);
619 /// ```
620 pub fn set_time<T>(mut self, v: T) -> Self
621 where
622 T: std::convert::Into<wkt::Timestamp>,
623 {
624 self.time = std::option::Option::Some(v.into());
625 self
626 }
627
628 /// Sets or clears the value of [time][crate::model::span::TimeEvent::time].
629 ///
630 /// # Example
631 /// ```ignore,no_run
632 /// # use google_cloud_trace_v2::model::span::TimeEvent;
633 /// use wkt::Timestamp;
634 /// let x = TimeEvent::new().set_or_clear_time(Some(Timestamp::default()/* use setters */));
635 /// let x = TimeEvent::new().set_or_clear_time(None::<Timestamp>);
636 /// ```
637 pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
638 where
639 T: std::convert::Into<wkt::Timestamp>,
640 {
641 self.time = v.map(|x| x.into());
642 self
643 }
644
645 /// Sets the value of [value][crate::model::span::TimeEvent::value].
646 ///
647 /// Note that all the setters affecting `value` are mutually
648 /// exclusive.
649 ///
650 /// # Example
651 /// ```ignore,no_run
652 /// # use google_cloud_trace_v2::model::span::TimeEvent;
653 /// use google_cloud_trace_v2::model::span::time_event::Annotation;
654 /// let x = TimeEvent::new().set_value(Some(
655 /// google_cloud_trace_v2::model::span::time_event::Value::Annotation(Annotation::default().into())));
656 /// ```
657 pub fn set_value<
658 T: std::convert::Into<std::option::Option<crate::model::span::time_event::Value>>,
659 >(
660 mut self,
661 v: T,
662 ) -> Self {
663 self.value = v.into();
664 self
665 }
666
667 /// The value of [value][crate::model::span::TimeEvent::value]
668 /// if it holds a `Annotation`, `None` if the field is not set or
669 /// holds a different branch.
670 pub fn annotation(
671 &self,
672 ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::Annotation>>
673 {
674 #[allow(unreachable_patterns)]
675 self.value.as_ref().and_then(|v| match v {
676 crate::model::span::time_event::Value::Annotation(v) => {
677 std::option::Option::Some(v)
678 }
679 _ => std::option::Option::None,
680 })
681 }
682
683 /// Sets the value of [value][crate::model::span::TimeEvent::value]
684 /// to hold a `Annotation`.
685 ///
686 /// Note that all the setters affecting `value` are
687 /// mutually exclusive.
688 ///
689 /// # Example
690 /// ```ignore,no_run
691 /// # use google_cloud_trace_v2::model::span::TimeEvent;
692 /// use google_cloud_trace_v2::model::span::time_event::Annotation;
693 /// let x = TimeEvent::new().set_annotation(Annotation::default()/* use setters */);
694 /// assert!(x.annotation().is_some());
695 /// assert!(x.message_event().is_none());
696 /// ```
697 pub fn set_annotation<
698 T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::Annotation>>,
699 >(
700 mut self,
701 v: T,
702 ) -> Self {
703 self.value = std::option::Option::Some(
704 crate::model::span::time_event::Value::Annotation(v.into()),
705 );
706 self
707 }
708
709 /// The value of [value][crate::model::span::TimeEvent::value]
710 /// if it holds a `MessageEvent`, `None` if the field is not set or
711 /// holds a different branch.
712 pub fn message_event(
713 &self,
714 ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::MessageEvent>>
715 {
716 #[allow(unreachable_patterns)]
717 self.value.as_ref().and_then(|v| match v {
718 crate::model::span::time_event::Value::MessageEvent(v) => {
719 std::option::Option::Some(v)
720 }
721 _ => std::option::Option::None,
722 })
723 }
724
725 /// Sets the value of [value][crate::model::span::TimeEvent::value]
726 /// to hold a `MessageEvent`.
727 ///
728 /// Note that all the setters affecting `value` are
729 /// mutually exclusive.
730 ///
731 /// # Example
732 /// ```ignore,no_run
733 /// # use google_cloud_trace_v2::model::span::TimeEvent;
734 /// use google_cloud_trace_v2::model::span::time_event::MessageEvent;
735 /// let x = TimeEvent::new().set_message_event(MessageEvent::default()/* use setters */);
736 /// assert!(x.message_event().is_some());
737 /// assert!(x.annotation().is_none());
738 /// ```
739 pub fn set_message_event<
740 T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::MessageEvent>>,
741 >(
742 mut self,
743 v: T,
744 ) -> Self {
745 self.value = std::option::Option::Some(
746 crate::model::span::time_event::Value::MessageEvent(v.into()),
747 );
748 self
749 }
750 }
751
752 impl wkt::message::Message for TimeEvent {
753 fn typename() -> &'static str {
754 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent"
755 }
756 }
757
758 /// Defines additional types related to [TimeEvent].
759 pub mod time_event {
760 #[allow(unused_imports)]
761 use super::*;
762
763 /// Text annotation with a set of attributes.
764 #[derive(Clone, Default, PartialEq)]
765 #[non_exhaustive]
766 pub struct Annotation {
767 /// A user-supplied message describing the event. The maximum length for
768 /// the description is 256 bytes.
769 pub description: std::option::Option<crate::model::TruncatableString>,
770
771 /// A set of attributes on the annotation. You can have up to 4 attributes
772 /// per Annotation.
773 pub attributes: std::option::Option<crate::model::span::Attributes>,
774
775 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
776 }
777
778 impl Annotation {
779 pub fn new() -> Self {
780 std::default::Default::default()
781 }
782
783 /// Sets the value of [description][crate::model::span::time_event::Annotation::description].
784 ///
785 /// # Example
786 /// ```ignore,no_run
787 /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
788 /// use google_cloud_trace_v2::model::TruncatableString;
789 /// let x = Annotation::new().set_description(TruncatableString::default()/* use setters */);
790 /// ```
791 pub fn set_description<T>(mut self, v: T) -> Self
792 where
793 T: std::convert::Into<crate::model::TruncatableString>,
794 {
795 self.description = std::option::Option::Some(v.into());
796 self
797 }
798
799 /// Sets or clears the value of [description][crate::model::span::time_event::Annotation::description].
800 ///
801 /// # Example
802 /// ```ignore,no_run
803 /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
804 /// use google_cloud_trace_v2::model::TruncatableString;
805 /// let x = Annotation::new().set_or_clear_description(Some(TruncatableString::default()/* use setters */));
806 /// let x = Annotation::new().set_or_clear_description(None::<TruncatableString>);
807 /// ```
808 pub fn set_or_clear_description<T>(mut self, v: std::option::Option<T>) -> Self
809 where
810 T: std::convert::Into<crate::model::TruncatableString>,
811 {
812 self.description = v.map(|x| x.into());
813 self
814 }
815
816 /// Sets the value of [attributes][crate::model::span::time_event::Annotation::attributes].
817 ///
818 /// # Example
819 /// ```ignore,no_run
820 /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
821 /// use google_cloud_trace_v2::model::span::Attributes;
822 /// let x = Annotation::new().set_attributes(Attributes::default()/* use setters */);
823 /// ```
824 pub fn set_attributes<T>(mut self, v: T) -> Self
825 where
826 T: std::convert::Into<crate::model::span::Attributes>,
827 {
828 self.attributes = std::option::Option::Some(v.into());
829 self
830 }
831
832 /// Sets or clears the value of [attributes][crate::model::span::time_event::Annotation::attributes].
833 ///
834 /// # Example
835 /// ```ignore,no_run
836 /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
837 /// use google_cloud_trace_v2::model::span::Attributes;
838 /// let x = Annotation::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
839 /// let x = Annotation::new().set_or_clear_attributes(None::<Attributes>);
840 /// ```
841 pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
842 where
843 T: std::convert::Into<crate::model::span::Attributes>,
844 {
845 self.attributes = v.map(|x| x.into());
846 self
847 }
848 }
849
850 impl wkt::message::Message for Annotation {
851 fn typename() -> &'static str {
852 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation"
853 }
854 }
855
856 /// An event describing a message sent/received between Spans.
857 #[derive(Clone, Default, PartialEq)]
858 #[non_exhaustive]
859 pub struct MessageEvent {
860 /// Type of MessageEvent. Indicates whether the message was sent or
861 /// received.
862 pub r#type: crate::model::span::time_event::message_event::Type,
863
864 /// An identifier for the MessageEvent's message that can be used to match
865 /// `SENT` and `RECEIVED` MessageEvents.
866 pub id: i64,
867
868 /// The number of uncompressed bytes sent or received.
869 pub uncompressed_size_bytes: i64,
870
871 /// The number of compressed bytes sent or received. If missing, the
872 /// compressed size is assumed to be the same size as the uncompressed
873 /// size.
874 pub compressed_size_bytes: i64,
875
876 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
877 }
878
879 impl MessageEvent {
880 pub fn new() -> Self {
881 std::default::Default::default()
882 }
883
884 /// Sets the value of [r#type][crate::model::span::time_event::MessageEvent::type].
885 ///
886 /// # Example
887 /// ```ignore,no_run
888 /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
889 /// use google_cloud_trace_v2::model::span::time_event::message_event::Type;
890 /// let x0 = MessageEvent::new().set_type(Type::Sent);
891 /// let x1 = MessageEvent::new().set_type(Type::Received);
892 /// ```
893 pub fn set_type<
894 T: std::convert::Into<crate::model::span::time_event::message_event::Type>,
895 >(
896 mut self,
897 v: T,
898 ) -> Self {
899 self.r#type = v.into();
900 self
901 }
902
903 /// Sets the value of [id][crate::model::span::time_event::MessageEvent::id].
904 ///
905 /// # Example
906 /// ```ignore,no_run
907 /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
908 /// let x = MessageEvent::new().set_id(42);
909 /// ```
910 pub fn set_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
911 self.id = v.into();
912 self
913 }
914
915 /// Sets the value of [uncompressed_size_bytes][crate::model::span::time_event::MessageEvent::uncompressed_size_bytes].
916 ///
917 /// # Example
918 /// ```ignore,no_run
919 /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
920 /// let x = MessageEvent::new().set_uncompressed_size_bytes(42);
921 /// ```
922 pub fn set_uncompressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
923 self.uncompressed_size_bytes = v.into();
924 self
925 }
926
927 /// Sets the value of [compressed_size_bytes][crate::model::span::time_event::MessageEvent::compressed_size_bytes].
928 ///
929 /// # Example
930 /// ```ignore,no_run
931 /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
932 /// let x = MessageEvent::new().set_compressed_size_bytes(42);
933 /// ```
934 pub fn set_compressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
935 self.compressed_size_bytes = v.into();
936 self
937 }
938 }
939
940 impl wkt::message::Message for MessageEvent {
941 fn typename() -> &'static str {
942 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent"
943 }
944 }
945
946 /// Defines additional types related to [MessageEvent].
947 pub mod message_event {
948 #[allow(unused_imports)]
949 use super::*;
950
951 /// Indicates whether the message was sent or received.
952 ///
953 /// # Working with unknown values
954 ///
955 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
956 /// additional enum variants at any time. Adding new variants is not considered
957 /// a breaking change. Applications should write their code in anticipation of:
958 ///
959 /// - New values appearing in future releases of the client library, **and**
960 /// - New values received dynamically, without application changes.
961 ///
962 /// Please consult the [Working with enums] section in the user guide for some
963 /// guidelines.
964 ///
965 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
966 #[derive(Clone, Debug, PartialEq)]
967 #[non_exhaustive]
968 pub enum Type {
969 /// Unknown event type.
970 Unspecified,
971 /// Indicates a sent message.
972 Sent,
973 /// Indicates a received message.
974 Received,
975 /// If set, the enum was initialized with an unknown value.
976 ///
977 /// Applications can examine the value using [Type::value] or
978 /// [Type::name].
979 UnknownValue(r#type::UnknownValue),
980 }
981
982 #[doc(hidden)]
983 pub mod r#type {
984 #[allow(unused_imports)]
985 use super::*;
986 #[derive(Clone, Debug, PartialEq)]
987 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
988 }
989
990 impl Type {
991 /// Gets the enum value.
992 ///
993 /// Returns `None` if the enum contains an unknown value deserialized from
994 /// the string representation of enums.
995 pub fn value(&self) -> std::option::Option<i32> {
996 match self {
997 Self::Unspecified => std::option::Option::Some(0),
998 Self::Sent => std::option::Option::Some(1),
999 Self::Received => std::option::Option::Some(2),
1000 Self::UnknownValue(u) => u.0.value(),
1001 }
1002 }
1003
1004 /// Gets the enum value as a string.
1005 ///
1006 /// Returns `None` if the enum contains an unknown value deserialized from
1007 /// the integer representation of enums.
1008 pub fn name(&self) -> std::option::Option<&str> {
1009 match self {
1010 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
1011 Self::Sent => std::option::Option::Some("SENT"),
1012 Self::Received => std::option::Option::Some("RECEIVED"),
1013 Self::UnknownValue(u) => u.0.name(),
1014 }
1015 }
1016 }
1017
1018 impl std::default::Default for Type {
1019 fn default() -> Self {
1020 use std::convert::From;
1021 Self::from(0)
1022 }
1023 }
1024
1025 impl std::fmt::Display for Type {
1026 fn fmt(
1027 &self,
1028 f: &mut std::fmt::Formatter<'_>,
1029 ) -> std::result::Result<(), std::fmt::Error> {
1030 wkt::internal::display_enum(f, self.name(), self.value())
1031 }
1032 }
1033
1034 impl std::convert::From<i32> for Type {
1035 fn from(value: i32) -> Self {
1036 match value {
1037 0 => Self::Unspecified,
1038 1 => Self::Sent,
1039 2 => Self::Received,
1040 _ => Self::UnknownValue(r#type::UnknownValue(
1041 wkt::internal::UnknownEnumValue::Integer(value),
1042 )),
1043 }
1044 }
1045 }
1046
1047 impl std::convert::From<&str> for Type {
1048 fn from(value: &str) -> Self {
1049 use std::string::ToString;
1050 match value {
1051 "TYPE_UNSPECIFIED" => Self::Unspecified,
1052 "SENT" => Self::Sent,
1053 "RECEIVED" => Self::Received,
1054 _ => Self::UnknownValue(r#type::UnknownValue(
1055 wkt::internal::UnknownEnumValue::String(value.to_string()),
1056 )),
1057 }
1058 }
1059 }
1060
1061 impl serde::ser::Serialize for Type {
1062 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1063 where
1064 S: serde::Serializer,
1065 {
1066 match self {
1067 Self::Unspecified => serializer.serialize_i32(0),
1068 Self::Sent => serializer.serialize_i32(1),
1069 Self::Received => serializer.serialize_i32(2),
1070 Self::UnknownValue(u) => u.0.serialize(serializer),
1071 }
1072 }
1073 }
1074
1075 impl<'de> serde::de::Deserialize<'de> for Type {
1076 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1077 where
1078 D: serde::Deserializer<'de>,
1079 {
1080 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1081 ".google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type",
1082 ))
1083 }
1084 }
1085 }
1086
1087 /// A `TimeEvent` can contain either an `Annotation` object or a
1088 /// `MessageEvent` object, but not both.
1089 #[derive(Clone, Debug, PartialEq)]
1090 #[non_exhaustive]
1091 pub enum Value {
1092 /// Text annotation with a set of attributes.
1093 Annotation(std::boxed::Box<crate::model::span::time_event::Annotation>),
1094 /// An event describing a message sent/received between Spans.
1095 MessageEvent(std::boxed::Box<crate::model::span::time_event::MessageEvent>),
1096 }
1097 }
1098
1099 /// A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation
1100 /// on the span, consisting of either user-supplied key:value pairs, or
1101 /// details of a message sent/received between Spans.
1102 #[derive(Clone, Default, PartialEq)]
1103 #[non_exhaustive]
1104 pub struct TimeEvents {
1105 /// A collection of `TimeEvent`s.
1106 pub time_event: std::vec::Vec<crate::model::span::TimeEvent>,
1107
1108 /// The number of dropped annotations in all the included time events.
1109 /// If the value is 0, then no annotations were dropped.
1110 pub dropped_annotations_count: i32,
1111
1112 /// The number of dropped message events in all the included time events.
1113 /// If the value is 0, then no message events were dropped.
1114 pub dropped_message_events_count: i32,
1115
1116 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1117 }
1118
1119 impl TimeEvents {
1120 pub fn new() -> Self {
1121 std::default::Default::default()
1122 }
1123
1124 /// Sets the value of [time_event][crate::model::span::TimeEvents::time_event].
1125 ///
1126 /// # Example
1127 /// ```ignore,no_run
1128 /// # use google_cloud_trace_v2::model::span::TimeEvents;
1129 /// use google_cloud_trace_v2::model::span::TimeEvent;
1130 /// let x = TimeEvents::new()
1131 /// .set_time_event([
1132 /// TimeEvent::default()/* use setters */,
1133 /// TimeEvent::default()/* use (different) setters */,
1134 /// ]);
1135 /// ```
1136 pub fn set_time_event<T, V>(mut self, v: T) -> Self
1137 where
1138 T: std::iter::IntoIterator<Item = V>,
1139 V: std::convert::Into<crate::model::span::TimeEvent>,
1140 {
1141 use std::iter::Iterator;
1142 self.time_event = v.into_iter().map(|i| i.into()).collect();
1143 self
1144 }
1145
1146 /// Sets the value of [dropped_annotations_count][crate::model::span::TimeEvents::dropped_annotations_count].
1147 ///
1148 /// # Example
1149 /// ```ignore,no_run
1150 /// # use google_cloud_trace_v2::model::span::TimeEvents;
1151 /// let x = TimeEvents::new().set_dropped_annotations_count(42);
1152 /// ```
1153 pub fn set_dropped_annotations_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1154 self.dropped_annotations_count = v.into();
1155 self
1156 }
1157
1158 /// Sets the value of [dropped_message_events_count][crate::model::span::TimeEvents::dropped_message_events_count].
1159 ///
1160 /// # Example
1161 /// ```ignore,no_run
1162 /// # use google_cloud_trace_v2::model::span::TimeEvents;
1163 /// let x = TimeEvents::new().set_dropped_message_events_count(42);
1164 /// ```
1165 pub fn set_dropped_message_events_count<T: std::convert::Into<i32>>(
1166 mut self,
1167 v: T,
1168 ) -> Self {
1169 self.dropped_message_events_count = v.into();
1170 self
1171 }
1172 }
1173
1174 impl wkt::message::Message for TimeEvents {
1175 fn typename() -> &'static str {
1176 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvents"
1177 }
1178 }
1179
1180 /// A pointer from the current span to another span in the same trace or in a
1181 /// different trace. For example, this can be used in batching operations,
1182 /// where a single batch handler processes multiple requests from different
1183 /// traces or when the handler receives a request from a different project.
1184 #[derive(Clone, Default, PartialEq)]
1185 #[non_exhaustive]
1186 pub struct Link {
1187 /// The `[TRACE_ID]` for a trace within a project.
1188 pub trace_id: std::string::String,
1189
1190 /// The `[SPAN_ID]` for a span within a trace.
1191 pub span_id: std::string::String,
1192
1193 /// The relationship of the current span relative to the linked span.
1194 pub r#type: crate::model::span::link::Type,
1195
1196 /// A set of attributes on the link. Up to 32 attributes can be
1197 /// specified per link.
1198 pub attributes: std::option::Option<crate::model::span::Attributes>,
1199
1200 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1201 }
1202
1203 impl Link {
1204 pub fn new() -> Self {
1205 std::default::Default::default()
1206 }
1207
1208 /// Sets the value of [trace_id][crate::model::span::Link::trace_id].
1209 ///
1210 /// # Example
1211 /// ```ignore,no_run
1212 /// # use google_cloud_trace_v2::model::span::Link;
1213 /// let x = Link::new().set_trace_id("example");
1214 /// ```
1215 pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1216 self.trace_id = v.into();
1217 self
1218 }
1219
1220 /// Sets the value of [span_id][crate::model::span::Link::span_id].
1221 ///
1222 /// # Example
1223 /// ```ignore,no_run
1224 /// # use google_cloud_trace_v2::model::span::Link;
1225 /// let x = Link::new().set_span_id("example");
1226 /// ```
1227 pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1228 self.span_id = v.into();
1229 self
1230 }
1231
1232 /// Sets the value of [r#type][crate::model::span::Link::type].
1233 ///
1234 /// # Example
1235 /// ```ignore,no_run
1236 /// # use google_cloud_trace_v2::model::span::Link;
1237 /// use google_cloud_trace_v2::model::span::link::Type;
1238 /// let x0 = Link::new().set_type(Type::ChildLinkedSpan);
1239 /// let x1 = Link::new().set_type(Type::ParentLinkedSpan);
1240 /// ```
1241 pub fn set_type<T: std::convert::Into<crate::model::span::link::Type>>(
1242 mut self,
1243 v: T,
1244 ) -> Self {
1245 self.r#type = v.into();
1246 self
1247 }
1248
1249 /// Sets the value of [attributes][crate::model::span::Link::attributes].
1250 ///
1251 /// # Example
1252 /// ```ignore,no_run
1253 /// # use google_cloud_trace_v2::model::span::Link;
1254 /// use google_cloud_trace_v2::model::span::Attributes;
1255 /// let x = Link::new().set_attributes(Attributes::default()/* use setters */);
1256 /// ```
1257 pub fn set_attributes<T>(mut self, v: T) -> Self
1258 where
1259 T: std::convert::Into<crate::model::span::Attributes>,
1260 {
1261 self.attributes = std::option::Option::Some(v.into());
1262 self
1263 }
1264
1265 /// Sets or clears the value of [attributes][crate::model::span::Link::attributes].
1266 ///
1267 /// # Example
1268 /// ```ignore,no_run
1269 /// # use google_cloud_trace_v2::model::span::Link;
1270 /// use google_cloud_trace_v2::model::span::Attributes;
1271 /// let x = Link::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
1272 /// let x = Link::new().set_or_clear_attributes(None::<Attributes>);
1273 /// ```
1274 pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
1275 where
1276 T: std::convert::Into<crate::model::span::Attributes>,
1277 {
1278 self.attributes = v.map(|x| x.into());
1279 self
1280 }
1281 }
1282
1283 impl wkt::message::Message for Link {
1284 fn typename() -> &'static str {
1285 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Link"
1286 }
1287 }
1288
1289 /// Defines additional types related to [Link].
1290 pub mod link {
1291 #[allow(unused_imports)]
1292 use super::*;
1293
1294 /// The relationship of the current span relative to the linked span: child,
1295 /// parent, or unspecified.
1296 ///
1297 /// # Working with unknown values
1298 ///
1299 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1300 /// additional enum variants at any time. Adding new variants is not considered
1301 /// a breaking change. Applications should write their code in anticipation of:
1302 ///
1303 /// - New values appearing in future releases of the client library, **and**
1304 /// - New values received dynamically, without application changes.
1305 ///
1306 /// Please consult the [Working with enums] section in the user guide for some
1307 /// guidelines.
1308 ///
1309 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1310 #[derive(Clone, Debug, PartialEq)]
1311 #[non_exhaustive]
1312 pub enum Type {
1313 /// The relationship of the two spans is unknown.
1314 Unspecified,
1315 /// The linked span is a child of the current span.
1316 ChildLinkedSpan,
1317 /// The linked span is a parent of the current span.
1318 ParentLinkedSpan,
1319 /// If set, the enum was initialized with an unknown value.
1320 ///
1321 /// Applications can examine the value using [Type::value] or
1322 /// [Type::name].
1323 UnknownValue(r#type::UnknownValue),
1324 }
1325
1326 #[doc(hidden)]
1327 pub mod r#type {
1328 #[allow(unused_imports)]
1329 use super::*;
1330 #[derive(Clone, Debug, PartialEq)]
1331 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1332 }
1333
1334 impl Type {
1335 /// Gets the enum value.
1336 ///
1337 /// Returns `None` if the enum contains an unknown value deserialized from
1338 /// the string representation of enums.
1339 pub fn value(&self) -> std::option::Option<i32> {
1340 match self {
1341 Self::Unspecified => std::option::Option::Some(0),
1342 Self::ChildLinkedSpan => std::option::Option::Some(1),
1343 Self::ParentLinkedSpan => std::option::Option::Some(2),
1344 Self::UnknownValue(u) => u.0.value(),
1345 }
1346 }
1347
1348 /// Gets the enum value as a string.
1349 ///
1350 /// Returns `None` if the enum contains an unknown value deserialized from
1351 /// the integer representation of enums.
1352 pub fn name(&self) -> std::option::Option<&str> {
1353 match self {
1354 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
1355 Self::ChildLinkedSpan => std::option::Option::Some("CHILD_LINKED_SPAN"),
1356 Self::ParentLinkedSpan => std::option::Option::Some("PARENT_LINKED_SPAN"),
1357 Self::UnknownValue(u) => u.0.name(),
1358 }
1359 }
1360 }
1361
1362 impl std::default::Default for Type {
1363 fn default() -> Self {
1364 use std::convert::From;
1365 Self::from(0)
1366 }
1367 }
1368
1369 impl std::fmt::Display for Type {
1370 fn fmt(
1371 &self,
1372 f: &mut std::fmt::Formatter<'_>,
1373 ) -> std::result::Result<(), std::fmt::Error> {
1374 wkt::internal::display_enum(f, self.name(), self.value())
1375 }
1376 }
1377
1378 impl std::convert::From<i32> for Type {
1379 fn from(value: i32) -> Self {
1380 match value {
1381 0 => Self::Unspecified,
1382 1 => Self::ChildLinkedSpan,
1383 2 => Self::ParentLinkedSpan,
1384 _ => Self::UnknownValue(r#type::UnknownValue(
1385 wkt::internal::UnknownEnumValue::Integer(value),
1386 )),
1387 }
1388 }
1389 }
1390
1391 impl std::convert::From<&str> for Type {
1392 fn from(value: &str) -> Self {
1393 use std::string::ToString;
1394 match value {
1395 "TYPE_UNSPECIFIED" => Self::Unspecified,
1396 "CHILD_LINKED_SPAN" => Self::ChildLinkedSpan,
1397 "PARENT_LINKED_SPAN" => Self::ParentLinkedSpan,
1398 _ => Self::UnknownValue(r#type::UnknownValue(
1399 wkt::internal::UnknownEnumValue::String(value.to_string()),
1400 )),
1401 }
1402 }
1403 }
1404
1405 impl serde::ser::Serialize for Type {
1406 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1407 where
1408 S: serde::Serializer,
1409 {
1410 match self {
1411 Self::Unspecified => serializer.serialize_i32(0),
1412 Self::ChildLinkedSpan => serializer.serialize_i32(1),
1413 Self::ParentLinkedSpan => serializer.serialize_i32(2),
1414 Self::UnknownValue(u) => u.0.serialize(serializer),
1415 }
1416 }
1417 }
1418
1419 impl<'de> serde::de::Deserialize<'de> for Type {
1420 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1421 where
1422 D: serde::Deserializer<'de>,
1423 {
1424 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1425 ".google.devtools.cloudtrace.v2.Span.Link.Type",
1426 ))
1427 }
1428 }
1429 }
1430
1431 /// A collection of links, which are references from this span to a span
1432 /// in the same or different trace.
1433 #[derive(Clone, Default, PartialEq)]
1434 #[non_exhaustive]
1435 pub struct Links {
1436 /// A collection of links.
1437 pub link: std::vec::Vec<crate::model::span::Link>,
1438
1439 /// The number of dropped links after the maximum size was enforced. If
1440 /// this value is 0, then no links were dropped.
1441 pub dropped_links_count: i32,
1442
1443 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1444 }
1445
1446 impl Links {
1447 pub fn new() -> Self {
1448 std::default::Default::default()
1449 }
1450
1451 /// Sets the value of [link][crate::model::span::Links::link].
1452 ///
1453 /// # Example
1454 /// ```ignore,no_run
1455 /// # use google_cloud_trace_v2::model::span::Links;
1456 /// use google_cloud_trace_v2::model::span::Link;
1457 /// let x = Links::new()
1458 /// .set_link([
1459 /// Link::default()/* use setters */,
1460 /// Link::default()/* use (different) setters */,
1461 /// ]);
1462 /// ```
1463 pub fn set_link<T, V>(mut self, v: T) -> Self
1464 where
1465 T: std::iter::IntoIterator<Item = V>,
1466 V: std::convert::Into<crate::model::span::Link>,
1467 {
1468 use std::iter::Iterator;
1469 self.link = v.into_iter().map(|i| i.into()).collect();
1470 self
1471 }
1472
1473 /// Sets the value of [dropped_links_count][crate::model::span::Links::dropped_links_count].
1474 ///
1475 /// # Example
1476 /// ```ignore,no_run
1477 /// # use google_cloud_trace_v2::model::span::Links;
1478 /// let x = Links::new().set_dropped_links_count(42);
1479 /// ```
1480 pub fn set_dropped_links_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1481 self.dropped_links_count = v.into();
1482 self
1483 }
1484 }
1485
1486 impl wkt::message::Message for Links {
1487 fn typename() -> &'static str {
1488 "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Links"
1489 }
1490 }
1491
1492 /// Type of span. Can be used to specify additional relationships between spans
1493 /// in addition to a parent/child relationship.
1494 ///
1495 /// # Working with unknown values
1496 ///
1497 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1498 /// additional enum variants at any time. Adding new variants is not considered
1499 /// a breaking change. Applications should write their code in anticipation of:
1500 ///
1501 /// - New values appearing in future releases of the client library, **and**
1502 /// - New values received dynamically, without application changes.
1503 ///
1504 /// Please consult the [Working with enums] section in the user guide for some
1505 /// guidelines.
1506 ///
1507 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1508 #[derive(Clone, Debug, PartialEq)]
1509 #[non_exhaustive]
1510 pub enum SpanKind {
1511 /// Unspecified. Do NOT use as default.
1512 /// Implementations MAY assume SpanKind.INTERNAL to be default.
1513 Unspecified,
1514 /// Indicates that the span is used internally. Default value.
1515 Internal,
1516 /// Indicates that the span covers server-side handling of an RPC or other
1517 /// remote network request.
1518 Server,
1519 /// Indicates that the span covers the client-side wrapper around an RPC or
1520 /// other remote request.
1521 Client,
1522 /// Indicates that the span describes producer sending a message to a broker.
1523 /// Unlike client and server, there is no direct critical path latency
1524 /// relationship between producer and consumer spans (e.g. publishing a
1525 /// message to a pubsub service).
1526 Producer,
1527 /// Indicates that the span describes consumer receiving a message from a
1528 /// broker. Unlike client and server, there is no direct critical path
1529 /// latency relationship between producer and consumer spans (e.g. receiving
1530 /// a message from a pubsub service subscription).
1531 Consumer,
1532 /// If set, the enum was initialized with an unknown value.
1533 ///
1534 /// Applications can examine the value using [SpanKind::value] or
1535 /// [SpanKind::name].
1536 UnknownValue(span_kind::UnknownValue),
1537 }
1538
1539 #[doc(hidden)]
1540 pub mod span_kind {
1541 #[allow(unused_imports)]
1542 use super::*;
1543 #[derive(Clone, Debug, PartialEq)]
1544 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1545 }
1546
1547 impl SpanKind {
1548 /// Gets the enum value.
1549 ///
1550 /// Returns `None` if the enum contains an unknown value deserialized from
1551 /// the string representation of enums.
1552 pub fn value(&self) -> std::option::Option<i32> {
1553 match self {
1554 Self::Unspecified => std::option::Option::Some(0),
1555 Self::Internal => std::option::Option::Some(1),
1556 Self::Server => std::option::Option::Some(2),
1557 Self::Client => std::option::Option::Some(3),
1558 Self::Producer => std::option::Option::Some(4),
1559 Self::Consumer => std::option::Option::Some(5),
1560 Self::UnknownValue(u) => u.0.value(),
1561 }
1562 }
1563
1564 /// Gets the enum value as a string.
1565 ///
1566 /// Returns `None` if the enum contains an unknown value deserialized from
1567 /// the integer representation of enums.
1568 pub fn name(&self) -> std::option::Option<&str> {
1569 match self {
1570 Self::Unspecified => std::option::Option::Some("SPAN_KIND_UNSPECIFIED"),
1571 Self::Internal => std::option::Option::Some("INTERNAL"),
1572 Self::Server => std::option::Option::Some("SERVER"),
1573 Self::Client => std::option::Option::Some("CLIENT"),
1574 Self::Producer => std::option::Option::Some("PRODUCER"),
1575 Self::Consumer => std::option::Option::Some("CONSUMER"),
1576 Self::UnknownValue(u) => u.0.name(),
1577 }
1578 }
1579 }
1580
1581 impl std::default::Default for SpanKind {
1582 fn default() -> Self {
1583 use std::convert::From;
1584 Self::from(0)
1585 }
1586 }
1587
1588 impl std::fmt::Display for SpanKind {
1589 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1590 wkt::internal::display_enum(f, self.name(), self.value())
1591 }
1592 }
1593
1594 impl std::convert::From<i32> for SpanKind {
1595 fn from(value: i32) -> Self {
1596 match value {
1597 0 => Self::Unspecified,
1598 1 => Self::Internal,
1599 2 => Self::Server,
1600 3 => Self::Client,
1601 4 => Self::Producer,
1602 5 => Self::Consumer,
1603 _ => Self::UnknownValue(span_kind::UnknownValue(
1604 wkt::internal::UnknownEnumValue::Integer(value),
1605 )),
1606 }
1607 }
1608 }
1609
1610 impl std::convert::From<&str> for SpanKind {
1611 fn from(value: &str) -> Self {
1612 use std::string::ToString;
1613 match value {
1614 "SPAN_KIND_UNSPECIFIED" => Self::Unspecified,
1615 "INTERNAL" => Self::Internal,
1616 "SERVER" => Self::Server,
1617 "CLIENT" => Self::Client,
1618 "PRODUCER" => Self::Producer,
1619 "CONSUMER" => Self::Consumer,
1620 _ => Self::UnknownValue(span_kind::UnknownValue(
1621 wkt::internal::UnknownEnumValue::String(value.to_string()),
1622 )),
1623 }
1624 }
1625 }
1626
1627 impl serde::ser::Serialize for SpanKind {
1628 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1629 where
1630 S: serde::Serializer,
1631 {
1632 match self {
1633 Self::Unspecified => serializer.serialize_i32(0),
1634 Self::Internal => serializer.serialize_i32(1),
1635 Self::Server => serializer.serialize_i32(2),
1636 Self::Client => serializer.serialize_i32(3),
1637 Self::Producer => serializer.serialize_i32(4),
1638 Self::Consumer => serializer.serialize_i32(5),
1639 Self::UnknownValue(u) => u.0.serialize(serializer),
1640 }
1641 }
1642 }
1643
1644 impl<'de> serde::de::Deserialize<'de> for SpanKind {
1645 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1646 where
1647 D: serde::Deserializer<'de>,
1648 {
1649 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SpanKind>::new(
1650 ".google.devtools.cloudtrace.v2.Span.SpanKind",
1651 ))
1652 }
1653 }
1654}
1655
1656/// The allowed types for `[VALUE]` in a `[KEY]:[VALUE]` attribute.
1657#[derive(Clone, Default, PartialEq)]
1658#[non_exhaustive]
1659pub struct AttributeValue {
1660 /// The type of the value.
1661 pub value: std::option::Option<crate::model::attribute_value::Value>,
1662
1663 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1664}
1665
1666impl AttributeValue {
1667 pub fn new() -> Self {
1668 std::default::Default::default()
1669 }
1670
1671 /// Sets the value of [value][crate::model::AttributeValue::value].
1672 ///
1673 /// Note that all the setters affecting `value` are mutually
1674 /// exclusive.
1675 ///
1676 /// # Example
1677 /// ```ignore,no_run
1678 /// # use google_cloud_trace_v2::model::AttributeValue;
1679 /// use google_cloud_trace_v2::model::attribute_value::Value;
1680 /// let x = AttributeValue::new().set_value(Some(Value::IntValue(42)));
1681 /// ```
1682 pub fn set_value<
1683 T: std::convert::Into<std::option::Option<crate::model::attribute_value::Value>>,
1684 >(
1685 mut self,
1686 v: T,
1687 ) -> Self {
1688 self.value = v.into();
1689 self
1690 }
1691
1692 /// The value of [value][crate::model::AttributeValue::value]
1693 /// if it holds a `StringValue`, `None` if the field is not set or
1694 /// holds a different branch.
1695 pub fn string_value(
1696 &self,
1697 ) -> std::option::Option<&std::boxed::Box<crate::model::TruncatableString>> {
1698 #[allow(unreachable_patterns)]
1699 self.value.as_ref().and_then(|v| match v {
1700 crate::model::attribute_value::Value::StringValue(v) => std::option::Option::Some(v),
1701 _ => std::option::Option::None,
1702 })
1703 }
1704
1705 /// Sets the value of [value][crate::model::AttributeValue::value]
1706 /// to hold a `StringValue`.
1707 ///
1708 /// Note that all the setters affecting `value` are
1709 /// mutually exclusive.
1710 ///
1711 /// # Example
1712 /// ```ignore,no_run
1713 /// # use google_cloud_trace_v2::model::AttributeValue;
1714 /// use google_cloud_trace_v2::model::TruncatableString;
1715 /// let x = AttributeValue::new().set_string_value(TruncatableString::default()/* use setters */);
1716 /// assert!(x.string_value().is_some());
1717 /// assert!(x.int_value().is_none());
1718 /// assert!(x.bool_value().is_none());
1719 /// ```
1720 pub fn set_string_value<
1721 T: std::convert::Into<std::boxed::Box<crate::model::TruncatableString>>,
1722 >(
1723 mut self,
1724 v: T,
1725 ) -> Self {
1726 self.value =
1727 std::option::Option::Some(crate::model::attribute_value::Value::StringValue(v.into()));
1728 self
1729 }
1730
1731 /// The value of [value][crate::model::AttributeValue::value]
1732 /// if it holds a `IntValue`, `None` if the field is not set or
1733 /// holds a different branch.
1734 pub fn int_value(&self) -> std::option::Option<&i64> {
1735 #[allow(unreachable_patterns)]
1736 self.value.as_ref().and_then(|v| match v {
1737 crate::model::attribute_value::Value::IntValue(v) => std::option::Option::Some(v),
1738 _ => std::option::Option::None,
1739 })
1740 }
1741
1742 /// Sets the value of [value][crate::model::AttributeValue::value]
1743 /// to hold a `IntValue`.
1744 ///
1745 /// Note that all the setters affecting `value` are
1746 /// mutually exclusive.
1747 ///
1748 /// # Example
1749 /// ```ignore,no_run
1750 /// # use google_cloud_trace_v2::model::AttributeValue;
1751 /// let x = AttributeValue::new().set_int_value(42);
1752 /// assert!(x.int_value().is_some());
1753 /// assert!(x.string_value().is_none());
1754 /// assert!(x.bool_value().is_none());
1755 /// ```
1756 pub fn set_int_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1757 self.value =
1758 std::option::Option::Some(crate::model::attribute_value::Value::IntValue(v.into()));
1759 self
1760 }
1761
1762 /// The value of [value][crate::model::AttributeValue::value]
1763 /// if it holds a `BoolValue`, `None` if the field is not set or
1764 /// holds a different branch.
1765 pub fn bool_value(&self) -> std::option::Option<&bool> {
1766 #[allow(unreachable_patterns)]
1767 self.value.as_ref().and_then(|v| match v {
1768 crate::model::attribute_value::Value::BoolValue(v) => std::option::Option::Some(v),
1769 _ => std::option::Option::None,
1770 })
1771 }
1772
1773 /// Sets the value of [value][crate::model::AttributeValue::value]
1774 /// to hold a `BoolValue`.
1775 ///
1776 /// Note that all the setters affecting `value` are
1777 /// mutually exclusive.
1778 ///
1779 /// # Example
1780 /// ```ignore,no_run
1781 /// # use google_cloud_trace_v2::model::AttributeValue;
1782 /// let x = AttributeValue::new().set_bool_value(true);
1783 /// assert!(x.bool_value().is_some());
1784 /// assert!(x.string_value().is_none());
1785 /// assert!(x.int_value().is_none());
1786 /// ```
1787 pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1788 self.value =
1789 std::option::Option::Some(crate::model::attribute_value::Value::BoolValue(v.into()));
1790 self
1791 }
1792}
1793
1794impl wkt::message::Message for AttributeValue {
1795 fn typename() -> &'static str {
1796 "type.googleapis.com/google.devtools.cloudtrace.v2.AttributeValue"
1797 }
1798}
1799
1800/// Defines additional types related to [AttributeValue].
1801pub mod attribute_value {
1802 #[allow(unused_imports)]
1803 use super::*;
1804
1805 /// The type of the value.
1806 #[derive(Clone, Debug, PartialEq)]
1807 #[non_exhaustive]
1808 pub enum Value {
1809 /// A string up to 256 bytes long.
1810 StringValue(std::boxed::Box<crate::model::TruncatableString>),
1811 /// A 64-bit signed integer.
1812 IntValue(i64),
1813 /// A Boolean value represented by `true` or `false`.
1814 BoolValue(bool),
1815 }
1816}
1817
1818/// A call stack appearing in a trace.
1819#[derive(Clone, Default, PartialEq)]
1820#[non_exhaustive]
1821pub struct StackTrace {
1822 /// Stack frames in this stack trace. A maximum of 128 frames are allowed.
1823 pub stack_frames: std::option::Option<crate::model::stack_trace::StackFrames>,
1824
1825 /// The hash ID is used to conserve network bandwidth for duplicate
1826 /// stack traces within a single trace.
1827 ///
1828 /// Often multiple spans will have identical stack traces.
1829 /// The first occurrence of a stack trace should contain both the
1830 /// `stackFrame` content and a value in `stackTraceHashId`.
1831 ///
1832 /// Subsequent spans within the same request can refer
1833 /// to that stack trace by only setting `stackTraceHashId`.
1834 pub stack_trace_hash_id: i64,
1835
1836 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1837}
1838
1839impl StackTrace {
1840 pub fn new() -> Self {
1841 std::default::Default::default()
1842 }
1843
1844 /// Sets the value of [stack_frames][crate::model::StackTrace::stack_frames].
1845 ///
1846 /// # Example
1847 /// ```ignore,no_run
1848 /// # use google_cloud_trace_v2::model::StackTrace;
1849 /// use google_cloud_trace_v2::model::stack_trace::StackFrames;
1850 /// let x = StackTrace::new().set_stack_frames(StackFrames::default()/* use setters */);
1851 /// ```
1852 pub fn set_stack_frames<T>(mut self, v: T) -> Self
1853 where
1854 T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1855 {
1856 self.stack_frames = std::option::Option::Some(v.into());
1857 self
1858 }
1859
1860 /// Sets or clears the value of [stack_frames][crate::model::StackTrace::stack_frames].
1861 ///
1862 /// # Example
1863 /// ```ignore,no_run
1864 /// # use google_cloud_trace_v2::model::StackTrace;
1865 /// use google_cloud_trace_v2::model::stack_trace::StackFrames;
1866 /// let x = StackTrace::new().set_or_clear_stack_frames(Some(StackFrames::default()/* use setters */));
1867 /// let x = StackTrace::new().set_or_clear_stack_frames(None::<StackFrames>);
1868 /// ```
1869 pub fn set_or_clear_stack_frames<T>(mut self, v: std::option::Option<T>) -> Self
1870 where
1871 T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1872 {
1873 self.stack_frames = v.map(|x| x.into());
1874 self
1875 }
1876
1877 /// Sets the value of [stack_trace_hash_id][crate::model::StackTrace::stack_trace_hash_id].
1878 ///
1879 /// # Example
1880 /// ```ignore,no_run
1881 /// # use google_cloud_trace_v2::model::StackTrace;
1882 /// let x = StackTrace::new().set_stack_trace_hash_id(42);
1883 /// ```
1884 pub fn set_stack_trace_hash_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1885 self.stack_trace_hash_id = v.into();
1886 self
1887 }
1888}
1889
1890impl wkt::message::Message for StackTrace {
1891 fn typename() -> &'static str {
1892 "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace"
1893 }
1894}
1895
1896/// Defines additional types related to [StackTrace].
1897pub mod stack_trace {
1898 #[allow(unused_imports)]
1899 use super::*;
1900
1901 /// Represents a single stack frame in a stack trace.
1902 #[derive(Clone, Default, PartialEq)]
1903 #[non_exhaustive]
1904 pub struct StackFrame {
1905 /// The fully-qualified name that uniquely identifies the function or
1906 /// method that is active in this frame (up to 1024 bytes).
1907 pub function_name: std::option::Option<crate::model::TruncatableString>,
1908
1909 /// An un-mangled function name, if `function_name` is mangled.
1910 /// To get information about name mangling, run
1911 /// [this search](https://www.google.com/search?q=cxx+name+mangling).
1912 /// The name can be fully-qualified (up to 1024 bytes).
1913 pub original_function_name: std::option::Option<crate::model::TruncatableString>,
1914
1915 /// The name of the source file where the function call appears (up to 256
1916 /// bytes).
1917 pub file_name: std::option::Option<crate::model::TruncatableString>,
1918
1919 /// The line number in `file_name` where the function call appears.
1920 pub line_number: i64,
1921
1922 /// The column number where the function call appears, if available.
1923 /// This is important in JavaScript because of its anonymous functions.
1924 pub column_number: i64,
1925
1926 /// The binary module from where the code was loaded.
1927 pub load_module: std::option::Option<crate::model::Module>,
1928
1929 /// The version of the deployed source code (up to 128 bytes).
1930 pub source_version: std::option::Option<crate::model::TruncatableString>,
1931
1932 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1933 }
1934
1935 impl StackFrame {
1936 pub fn new() -> Self {
1937 std::default::Default::default()
1938 }
1939
1940 /// Sets the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1941 ///
1942 /// # Example
1943 /// ```ignore,no_run
1944 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1945 /// use google_cloud_trace_v2::model::TruncatableString;
1946 /// let x = StackFrame::new().set_function_name(TruncatableString::default()/* use setters */);
1947 /// ```
1948 pub fn set_function_name<T>(mut self, v: T) -> Self
1949 where
1950 T: std::convert::Into<crate::model::TruncatableString>,
1951 {
1952 self.function_name = std::option::Option::Some(v.into());
1953 self
1954 }
1955
1956 /// Sets or clears the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1957 ///
1958 /// # Example
1959 /// ```ignore,no_run
1960 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1961 /// use google_cloud_trace_v2::model::TruncatableString;
1962 /// let x = StackFrame::new().set_or_clear_function_name(Some(TruncatableString::default()/* use setters */));
1963 /// let x = StackFrame::new().set_or_clear_function_name(None::<TruncatableString>);
1964 /// ```
1965 pub fn set_or_clear_function_name<T>(mut self, v: std::option::Option<T>) -> Self
1966 where
1967 T: std::convert::Into<crate::model::TruncatableString>,
1968 {
1969 self.function_name = v.map(|x| x.into());
1970 self
1971 }
1972
1973 /// Sets the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
1974 ///
1975 /// # Example
1976 /// ```ignore,no_run
1977 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1978 /// use google_cloud_trace_v2::model::TruncatableString;
1979 /// let x = StackFrame::new().set_original_function_name(TruncatableString::default()/* use setters */);
1980 /// ```
1981 pub fn set_original_function_name<T>(mut self, v: T) -> Self
1982 where
1983 T: std::convert::Into<crate::model::TruncatableString>,
1984 {
1985 self.original_function_name = std::option::Option::Some(v.into());
1986 self
1987 }
1988
1989 /// Sets or clears the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
1990 ///
1991 /// # Example
1992 /// ```ignore,no_run
1993 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1994 /// use google_cloud_trace_v2::model::TruncatableString;
1995 /// let x = StackFrame::new().set_or_clear_original_function_name(Some(TruncatableString::default()/* use setters */));
1996 /// let x = StackFrame::new().set_or_clear_original_function_name(None::<TruncatableString>);
1997 /// ```
1998 pub fn set_or_clear_original_function_name<T>(mut self, v: std::option::Option<T>) -> Self
1999 where
2000 T: std::convert::Into<crate::model::TruncatableString>,
2001 {
2002 self.original_function_name = v.map(|x| x.into());
2003 self
2004 }
2005
2006 /// Sets the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
2007 ///
2008 /// # Example
2009 /// ```ignore,no_run
2010 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2011 /// use google_cloud_trace_v2::model::TruncatableString;
2012 /// let x = StackFrame::new().set_file_name(TruncatableString::default()/* use setters */);
2013 /// ```
2014 pub fn set_file_name<T>(mut self, v: T) -> Self
2015 where
2016 T: std::convert::Into<crate::model::TruncatableString>,
2017 {
2018 self.file_name = std::option::Option::Some(v.into());
2019 self
2020 }
2021
2022 /// Sets or clears the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
2023 ///
2024 /// # Example
2025 /// ```ignore,no_run
2026 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2027 /// use google_cloud_trace_v2::model::TruncatableString;
2028 /// let x = StackFrame::new().set_or_clear_file_name(Some(TruncatableString::default()/* use setters */));
2029 /// let x = StackFrame::new().set_or_clear_file_name(None::<TruncatableString>);
2030 /// ```
2031 pub fn set_or_clear_file_name<T>(mut self, v: std::option::Option<T>) -> Self
2032 where
2033 T: std::convert::Into<crate::model::TruncatableString>,
2034 {
2035 self.file_name = v.map(|x| x.into());
2036 self
2037 }
2038
2039 /// Sets the value of [line_number][crate::model::stack_trace::StackFrame::line_number].
2040 ///
2041 /// # Example
2042 /// ```ignore,no_run
2043 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2044 /// let x = StackFrame::new().set_line_number(42);
2045 /// ```
2046 pub fn set_line_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2047 self.line_number = v.into();
2048 self
2049 }
2050
2051 /// Sets the value of [column_number][crate::model::stack_trace::StackFrame::column_number].
2052 ///
2053 /// # Example
2054 /// ```ignore,no_run
2055 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2056 /// let x = StackFrame::new().set_column_number(42);
2057 /// ```
2058 pub fn set_column_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2059 self.column_number = v.into();
2060 self
2061 }
2062
2063 /// Sets the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
2064 ///
2065 /// # Example
2066 /// ```ignore,no_run
2067 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2068 /// use google_cloud_trace_v2::model::Module;
2069 /// let x = StackFrame::new().set_load_module(Module::default()/* use setters */);
2070 /// ```
2071 pub fn set_load_module<T>(mut self, v: T) -> Self
2072 where
2073 T: std::convert::Into<crate::model::Module>,
2074 {
2075 self.load_module = std::option::Option::Some(v.into());
2076 self
2077 }
2078
2079 /// Sets or clears the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
2080 ///
2081 /// # Example
2082 /// ```ignore,no_run
2083 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2084 /// use google_cloud_trace_v2::model::Module;
2085 /// let x = StackFrame::new().set_or_clear_load_module(Some(Module::default()/* use setters */));
2086 /// let x = StackFrame::new().set_or_clear_load_module(None::<Module>);
2087 /// ```
2088 pub fn set_or_clear_load_module<T>(mut self, v: std::option::Option<T>) -> Self
2089 where
2090 T: std::convert::Into<crate::model::Module>,
2091 {
2092 self.load_module = v.map(|x| x.into());
2093 self
2094 }
2095
2096 /// Sets the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
2097 ///
2098 /// # Example
2099 /// ```ignore,no_run
2100 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2101 /// use google_cloud_trace_v2::model::TruncatableString;
2102 /// let x = StackFrame::new().set_source_version(TruncatableString::default()/* use setters */);
2103 /// ```
2104 pub fn set_source_version<T>(mut self, v: T) -> Self
2105 where
2106 T: std::convert::Into<crate::model::TruncatableString>,
2107 {
2108 self.source_version = std::option::Option::Some(v.into());
2109 self
2110 }
2111
2112 /// Sets or clears the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
2113 ///
2114 /// # Example
2115 /// ```ignore,no_run
2116 /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2117 /// use google_cloud_trace_v2::model::TruncatableString;
2118 /// let x = StackFrame::new().set_or_clear_source_version(Some(TruncatableString::default()/* use setters */));
2119 /// let x = StackFrame::new().set_or_clear_source_version(None::<TruncatableString>);
2120 /// ```
2121 pub fn set_or_clear_source_version<T>(mut self, v: std::option::Option<T>) -> Self
2122 where
2123 T: std::convert::Into<crate::model::TruncatableString>,
2124 {
2125 self.source_version = v.map(|x| x.into());
2126 self
2127 }
2128 }
2129
2130 impl wkt::message::Message for StackFrame {
2131 fn typename() -> &'static str {
2132 "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrame"
2133 }
2134 }
2135
2136 /// A collection of stack frames, which can be truncated.
2137 #[derive(Clone, Default, PartialEq)]
2138 #[non_exhaustive]
2139 pub struct StackFrames {
2140 /// Stack frames in this call stack.
2141 pub frame: std::vec::Vec<crate::model::stack_trace::StackFrame>,
2142
2143 /// The number of stack frames that were dropped because there
2144 /// were too many stack frames.
2145 /// If this value is 0, then no stack frames were dropped.
2146 pub dropped_frames_count: i32,
2147
2148 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2149 }
2150
2151 impl StackFrames {
2152 pub fn new() -> Self {
2153 std::default::Default::default()
2154 }
2155
2156 /// Sets the value of [frame][crate::model::stack_trace::StackFrames::frame].
2157 ///
2158 /// # Example
2159 /// ```ignore,no_run
2160 /// # use google_cloud_trace_v2::model::stack_trace::StackFrames;
2161 /// use google_cloud_trace_v2::model::stack_trace::StackFrame;
2162 /// let x = StackFrames::new()
2163 /// .set_frame([
2164 /// StackFrame::default()/* use setters */,
2165 /// StackFrame::default()/* use (different) setters */,
2166 /// ]);
2167 /// ```
2168 pub fn set_frame<T, V>(mut self, v: T) -> Self
2169 where
2170 T: std::iter::IntoIterator<Item = V>,
2171 V: std::convert::Into<crate::model::stack_trace::StackFrame>,
2172 {
2173 use std::iter::Iterator;
2174 self.frame = v.into_iter().map(|i| i.into()).collect();
2175 self
2176 }
2177
2178 /// Sets the value of [dropped_frames_count][crate::model::stack_trace::StackFrames::dropped_frames_count].
2179 ///
2180 /// # Example
2181 /// ```ignore,no_run
2182 /// # use google_cloud_trace_v2::model::stack_trace::StackFrames;
2183 /// let x = StackFrames::new().set_dropped_frames_count(42);
2184 /// ```
2185 pub fn set_dropped_frames_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2186 self.dropped_frames_count = v.into();
2187 self
2188 }
2189 }
2190
2191 impl wkt::message::Message for StackFrames {
2192 fn typename() -> &'static str {
2193 "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrames"
2194 }
2195 }
2196}
2197
2198/// Binary module.
2199#[derive(Clone, Default, PartialEq)]
2200#[non_exhaustive]
2201pub struct Module {
2202 /// For example: main binary, kernel modules, and dynamic libraries
2203 /// such as libc.so, sharedlib.so (up to 256 bytes).
2204 pub module: std::option::Option<crate::model::TruncatableString>,
2205
2206 /// A unique identifier for the module, usually a hash of its
2207 /// contents (up to 128 bytes).
2208 pub build_id: std::option::Option<crate::model::TruncatableString>,
2209
2210 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2211}
2212
2213impl Module {
2214 pub fn new() -> Self {
2215 std::default::Default::default()
2216 }
2217
2218 /// Sets the value of [module][crate::model::Module::module].
2219 ///
2220 /// # Example
2221 /// ```ignore,no_run
2222 /// # use google_cloud_trace_v2::model::Module;
2223 /// use google_cloud_trace_v2::model::TruncatableString;
2224 /// let x = Module::new().set_module(TruncatableString::default()/* use setters */);
2225 /// ```
2226 pub fn set_module<T>(mut self, v: T) -> Self
2227 where
2228 T: std::convert::Into<crate::model::TruncatableString>,
2229 {
2230 self.module = std::option::Option::Some(v.into());
2231 self
2232 }
2233
2234 /// Sets or clears the value of [module][crate::model::Module::module].
2235 ///
2236 /// # Example
2237 /// ```ignore,no_run
2238 /// # use google_cloud_trace_v2::model::Module;
2239 /// use google_cloud_trace_v2::model::TruncatableString;
2240 /// let x = Module::new().set_or_clear_module(Some(TruncatableString::default()/* use setters */));
2241 /// let x = Module::new().set_or_clear_module(None::<TruncatableString>);
2242 /// ```
2243 pub fn set_or_clear_module<T>(mut self, v: std::option::Option<T>) -> Self
2244 where
2245 T: std::convert::Into<crate::model::TruncatableString>,
2246 {
2247 self.module = v.map(|x| x.into());
2248 self
2249 }
2250
2251 /// Sets the value of [build_id][crate::model::Module::build_id].
2252 ///
2253 /// # Example
2254 /// ```ignore,no_run
2255 /// # use google_cloud_trace_v2::model::Module;
2256 /// use google_cloud_trace_v2::model::TruncatableString;
2257 /// let x = Module::new().set_build_id(TruncatableString::default()/* use setters */);
2258 /// ```
2259 pub fn set_build_id<T>(mut self, v: T) -> Self
2260 where
2261 T: std::convert::Into<crate::model::TruncatableString>,
2262 {
2263 self.build_id = std::option::Option::Some(v.into());
2264 self
2265 }
2266
2267 /// Sets or clears the value of [build_id][crate::model::Module::build_id].
2268 ///
2269 /// # Example
2270 /// ```ignore,no_run
2271 /// # use google_cloud_trace_v2::model::Module;
2272 /// use google_cloud_trace_v2::model::TruncatableString;
2273 /// let x = Module::new().set_or_clear_build_id(Some(TruncatableString::default()/* use setters */));
2274 /// let x = Module::new().set_or_clear_build_id(None::<TruncatableString>);
2275 /// ```
2276 pub fn set_or_clear_build_id<T>(mut self, v: std::option::Option<T>) -> Self
2277 where
2278 T: std::convert::Into<crate::model::TruncatableString>,
2279 {
2280 self.build_id = v.map(|x| x.into());
2281 self
2282 }
2283}
2284
2285impl wkt::message::Message for Module {
2286 fn typename() -> &'static str {
2287 "type.googleapis.com/google.devtools.cloudtrace.v2.Module"
2288 }
2289}
2290
2291/// Represents a string that might be shortened to a specified length.
2292#[derive(Clone, Default, PartialEq)]
2293#[non_exhaustive]
2294pub struct TruncatableString {
2295 /// The shortened string. For example, if the original string is 500
2296 /// bytes long and the limit of the string is 128 bytes, then
2297 /// `value` contains the first 128 bytes of the 500-byte string.
2298 ///
2299 /// Truncation always happens on a UTF8 character boundary. If there
2300 /// are multi-byte characters in the string, then the length of the
2301 /// shortened string might be less than the size limit.
2302 pub value: std::string::String,
2303
2304 /// The number of bytes removed from the original string. If this
2305 /// value is 0, then the string was not shortened.
2306 pub truncated_byte_count: i32,
2307
2308 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2309}
2310
2311impl TruncatableString {
2312 pub fn new() -> Self {
2313 std::default::Default::default()
2314 }
2315
2316 /// Sets the value of [value][crate::model::TruncatableString::value].
2317 ///
2318 /// # Example
2319 /// ```ignore,no_run
2320 /// # use google_cloud_trace_v2::model::TruncatableString;
2321 /// let x = TruncatableString::new().set_value("example");
2322 /// ```
2323 pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2324 self.value = v.into();
2325 self
2326 }
2327
2328 /// Sets the value of [truncated_byte_count][crate::model::TruncatableString::truncated_byte_count].
2329 ///
2330 /// # Example
2331 /// ```ignore,no_run
2332 /// # use google_cloud_trace_v2::model::TruncatableString;
2333 /// let x = TruncatableString::new().set_truncated_byte_count(42);
2334 /// ```
2335 pub fn set_truncated_byte_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2336 self.truncated_byte_count = v.into();
2337 self
2338 }
2339}
2340
2341impl wkt::message::Message for TruncatableString {
2342 fn typename() -> &'static str {
2343 "type.googleapis.com/google.devtools.cloudtrace.v2.TruncatableString"
2344 }
2345}
2346
2347/// The request message for the `BatchWriteSpans` method.
2348#[derive(Clone, Default, PartialEq)]
2349#[non_exhaustive]
2350pub struct BatchWriteSpansRequest {
2351 /// Required. The name of the project where the spans belong. The format is
2352 /// `projects/[PROJECT_ID]`.
2353 pub name: std::string::String,
2354
2355 /// Required. A list of new spans. The span names must not match existing
2356 /// spans, otherwise the results are undefined.
2357 pub spans: std::vec::Vec<crate::model::Span>,
2358
2359 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2360}
2361
2362impl BatchWriteSpansRequest {
2363 pub fn new() -> Self {
2364 std::default::Default::default()
2365 }
2366
2367 /// Sets the value of [name][crate::model::BatchWriteSpansRequest::name].
2368 ///
2369 /// # Example
2370 /// ```ignore,no_run
2371 /// # use google_cloud_trace_v2::model::BatchWriteSpansRequest;
2372 /// let x = BatchWriteSpansRequest::new().set_name("example");
2373 /// ```
2374 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2375 self.name = v.into();
2376 self
2377 }
2378
2379 /// Sets the value of [spans][crate::model::BatchWriteSpansRequest::spans].
2380 ///
2381 /// # Example
2382 /// ```ignore,no_run
2383 /// # use google_cloud_trace_v2::model::BatchWriteSpansRequest;
2384 /// use google_cloud_trace_v2::model::Span;
2385 /// let x = BatchWriteSpansRequest::new()
2386 /// .set_spans([
2387 /// Span::default()/* use setters */,
2388 /// Span::default()/* use (different) setters */,
2389 /// ]);
2390 /// ```
2391 pub fn set_spans<T, V>(mut self, v: T) -> Self
2392 where
2393 T: std::iter::IntoIterator<Item = V>,
2394 V: std::convert::Into<crate::model::Span>,
2395 {
2396 use std::iter::Iterator;
2397 self.spans = v.into_iter().map(|i| i.into()).collect();
2398 self
2399 }
2400}
2401
2402impl wkt::message::Message for BatchWriteSpansRequest {
2403 fn typename() -> &'static str {
2404 "type.googleapis.com/google.devtools.cloudtrace.v2.BatchWriteSpansRequest"
2405 }
2406}