pub struct Span<'a, P> { /* private fields */ }Expand description
A diagnostic event that represents a span in a distributed trace.
Spans are an extension of Events that explicitly take the well-known properties that signal an event as being a span. See the crate::span module for details.
A SpanEvent can be converted into an Event through its ToEvent implemenation, or passed directly to a crate::Emitter to emit it.
Implementations§
Source§impl<'a, P: Props> Span<'a, P>
impl<'a, P: Props> Span<'a, P>
Sourcepub fn new(
mdl: impl Into<Path<'a>>,
name: impl Into<Str<'a>>,
extent: impl ToExtent,
props: P,
) -> Self
pub fn new( mdl: impl Into<Path<'a>>, name: impl Into<Str<'a>>, extent: impl ToExtent, props: P, ) -> Self
Create a new span event from its parts.
Each span consists of:
mdl: The module that executed the operation the span is tracking.name: The name of the operation the span is tracking.extent: The time the operation spent executing. The extent should be a span.props: AdditionalPropsto associate with the span. These may include theSpanCtxtwith the trace and span ids for the span, or they may be part of the ambient context.
Sourcepub fn with_extent(self, extent: impl ToExtent) -> Self
pub fn with_extent(self, extent: impl ToExtent) -> Self
Set the extent of the span.
Sourcepub fn ts(&self) -> Option<&Timestamp>
pub fn ts(&self) -> Option<&Timestamp>
Get the extent of the metric as a point in time.
If the span has an extent then this method will return Some, with the result of Extent::as_point. If the span doesn’t have an extent then this method will return None.
Sourcepub fn ts_start(&self) -> Option<&Timestamp>
pub fn ts_start(&self) -> Option<&Timestamp>
Get the start point of the extent of the span.
If the span has an extent, and that extent covers a timespan then this method will return Some. Otherwise this method will return None.
Sourcepub fn with_props<U>(self, props: U) -> Span<'a, U>
pub fn with_props<U>(self, props: U) -> Span<'a, U>
Set the properties of the span.
Sourcepub fn map_props<U>(self, map: impl FnOnce(P) -> U) -> Span<'a, U>
pub fn map_props<U>(self, map: impl FnOnce(P) -> U) -> Span<'a, U>
Map the properties of the span.
Sourcepub fn erase<'b>(&'b self) -> Span<'b, &'b dyn ErasedProps>
pub fn erase<'b>(&'b self) -> Span<'b, &'b dyn ErasedProps>
Get a type-erased span, borrowing data from this one.
Trait Implementations§
Source§impl<'a, P: Props> Props for Span<'a, P>
impl<'a, P: Props> Props for Span<'a, P>
Source§fn for_each<'kv, F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>>(
&'kv self,
for_each: F,
) -> ControlFlow<()>
fn for_each<'kv, F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>>( &'kv self, for_each: F, ) -> ControlFlow<()>
Source§fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>where
K: ToStr,
fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>where
K: ToStr,
Source§fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
V. Read more