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