pub struct TraceSpan {
pub id: SpanId,
pub parent: Option<SpanId>,
pub name: String,
pub start_time: SystemTime,
pub end_time: Option<SystemTime>,
pub duration: Option<Duration>,
pub status: SpanStatus,
pub attributes: Vec<SpanAttribute>,
}Expand description
A single span in an execution trace.
Fields§
§id: SpanIdUnique span identifier.
parent: Option<SpanId>Optional parent span (for nesting).
name: StringHuman-readable name of the operation.
start_time: SystemTimeWhen the span started.
end_time: Option<SystemTime>When the span ended (if finished).
duration: Option<Duration>Duration (calculated when ended).
status: SpanStatusCurrent status of the span.
attributes: Vec<SpanAttribute>Arbitrary key-value attributes.
Implementations§
Source§impl TraceSpan
impl TraceSpan
Sourcepub fn start_child(id: SpanId, parent: &SpanId, name: impl Into<String>) -> Self
pub fn start_child(id: SpanId, parent: &SpanId, name: impl Into<String>) -> Self
Create a new child span.
Sourcepub fn finish(&mut self, status: SpanStatus)
pub fn finish(&mut self, status: SpanStatus)
End the span with the given status.
Sourcepub fn add_attribute(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
)
pub fn add_attribute( &mut self, key: impl Into<String>, value: impl Into<String>, )
Add an attribute to the span.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if this span is still running.
Sourcepub fn get_attribute(&self, key: &str) -> Option<&str>
pub fn get_attribute(&self, key: &str) -> Option<&str>
Get the attribute value for a given key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TraceSpan
impl RefUnwindSafe for TraceSpan
impl Send for TraceSpan
impl Sync for TraceSpan
impl Unpin for TraceSpan
impl UnsafeUnpin for TraceSpan
impl UnwindSafe for TraceSpan
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