opentelemetry_sdk/trace/
events.rs

1//! # Span Events
2
3use std::ops::Deref;
4
5use opentelemetry::trace::Event;
6/// Stores span events along with dropped count.
7#[derive(Clone, Debug, Default, PartialEq)]
8#[non_exhaustive]
9pub struct SpanEvents {
10    /// The events stored as a vector. Could be empty if there are no events.
11    pub events: Vec<Event>,
12    /// The number of Events dropped from the span.
13    pub dropped_count: u32,
14}
15
16impl Deref for SpanEvents {
17    type Target = [Event];
18
19    fn deref(&self) -> &Self::Target {
20        &self.events
21    }
22}
23
24impl IntoIterator for SpanEvents {
25    type Item = Event;
26    type IntoIter = std::vec::IntoIter<Self::Item>;
27
28    fn into_iter(self) -> Self::IntoIter {
29        self.events.into_iter()
30    }
31}
32
33impl SpanEvents {
34    pub(crate) fn add_event(&mut self, event: Event) {
35        self.events.push(event);
36    }
37}