pub struct Span {
pub name: String,
pub span_id: String,
pub trace_id: String,
pub parent_span_id: Option<String>,
pub start_time: SystemTime,
pub end_time: Option<SystemTime>,
pub attributes: HashMap<String, String>,
pub status: Option<String>,
}Expand description
Trace span representing a unit of work.
Fields§
§name: StringSpan name.
span_id: StringSpan ID (unique within a trace).
trace_id: StringTrace ID (groups related spans).
parent_span_id: Option<String>Parent span ID (if this is a child span).
start_time: SystemTimeWhen the span started.
end_time: Option<SystemTime>When the span ended (None if still active).
attributes: HashMap<String, String>Span attributes/tags.
status: Option<String>Span status (e.g., “OK”, “ERROR”).
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(name: impl Into<String>, trace_id: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, trace_id: impl Into<String>) -> Self
Creates a new span with the given name.
Sourcepub fn with_parent(self, parent_span_id: impl Into<String>) -> Self
pub fn with_parent(self, parent_span_id: impl Into<String>) -> Self
Sets the parent span ID.
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds an attribute to the span.
Sourcepub fn end_with_status(self, status: impl Into<String>) -> Self
pub fn end_with_status(self, status: impl Into<String>) -> Self
Ends the span with the given 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 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