pub struct Span {
pub context: SpanContext,
pub name: String,
pub start_ns: u64,
pub end_ns: Option<u64>,
pub attributes: HashMap<String, AttributeValue>,
pub events: Vec<SpanEvent>,
pub status: SpanStatus,
}Expand description
A single unit of work in a distributed trace.
Fields§
§context: SpanContextSampling and identity context.
name: StringHuman-readable operation name.
start_ns: u64Nanoseconds since UNIX epoch when the span started.
end_ns: Option<u64>Nanoseconds since UNIX epoch when the span ended, or None if still
in progress.
attributes: HashMap<String, AttributeValue>Key-value attributes describing the operation.
events: Vec<SpanEvent>Timestamped events that occurred during this span.
status: SpanStatusCompletion status of this span.
Implementations§
Source§impl Span
impl Span
Sourcepub fn set_attribute(&mut self, key: impl Into<String>, value: AttributeValue)
pub fn set_attribute(&mut self, key: impl Into<String>, value: AttributeValue)
Sets a key-value attribute on this span.
Sourcepub fn add_event(
&mut self,
name: impl Into<String>,
attributes: HashMap<String, AttributeValue>,
)
pub fn add_event( &mut self, name: impl Into<String>, attributes: HashMap<String, AttributeValue>, )
Appends a named event with optional attributes to this span.
Sourcepub fn duration_ns(&self) -> Option<u64>
pub fn duration_ns(&self) -> Option<u64>
Returns the duration of this span in nanoseconds, or None if it has
not yet finished.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request