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