pub struct Span {
pub name: String,
pub trace_id: String,
pub span_id: String,
pub parent_span_id: Option<String>,
pub kind: SpanKind,
pub start_time: Instant,
pub end_time: Option<Instant>,
pub status: SpanStatus,
pub attributes: HashMap<String, SpanValue>,
pub events: Vec<SpanEvent>,
}Expand description
A tracing span representing a unit of work
Fields§
§name: StringSpan name
trace_id: StringTrace ID
span_id: StringSpan ID
parent_span_id: Option<String>Parent span ID
kind: SpanKindSpan kind
start_time: InstantStart time
end_time: Option<Instant>End time (set when span ends)
status: SpanStatusSpan status
attributes: HashMap<String, SpanValue>Attributes
events: Vec<SpanEvent>Events
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(name: impl Into<String>, trace_id: String, span_id: String) -> Self
pub fn new(name: impl Into<String>, trace_id: String, span_id: String) -> Self
Create a new span
Sourcepub fn with_parent(self, parent_span_id: String) -> Self
pub fn with_parent(self, parent_span_id: String) -> Self
Set parent span ID
Sourcepub fn set_attribute(
&mut self,
key: impl Into<String>,
value: impl Into<SpanValue>,
)
pub fn set_attribute( &mut self, key: impl Into<String>, value: impl Into<SpanValue>, )
Set an attribute
Sourcepub fn add_event_with_attributes(
&mut self,
name: impl Into<String>,
attributes: HashMap<String, SpanValue>,
)
pub fn add_event_with_attributes( &mut self, name: impl Into<String>, attributes: HashMap<String, SpanValue>, )
Add an event with attributes
Sourcepub fn set_status(&mut self, status: SpanStatus)
pub fn set_status(&mut self, status: SpanStatus)
Set span status
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more