emit::span

Struct Span

Source
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>

Source

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: Additional Props to associate with the span. These may include the SpanCtxt with the trace and span ids for the span, or they may be part of the ambient context.
Source

pub fn mdl(&self) -> &Path<'a>

Get the module that executed the operation.

Source

pub fn with_mdl(self, mdl: impl Into<Path<'a>>) -> Self

Set the module of the span.

Source

pub fn name(&self) -> &Str<'a>

Get the name of the operation.

Source

pub fn with_name(self, name: impl Into<Str<'a>>) -> Self

Set the name of the span.

Source

pub fn extent(&self) -> Option<&Extent>

Get the time the operation spent executing.

Source

pub fn with_extent(self, extent: impl ToExtent) -> Self

Set the extent of the span.

Source

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.

Source

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.

Source

pub fn props(&self) -> &P

Get the additional properties associated with the span.

Source

pub fn with_props<U>(self, props: U) -> Span<'a, U>

Set the properties of the span.

Source

pub fn map_props<U>(self, map: impl FnOnce(P) -> U) -> Span<'a, U>

Map the properties of the span.

Source

pub fn tpl(&self) -> &Template<'a>

Get the template that will be used to render the span.

Source

pub fn with_tpl(self, tpl: impl Into<Template<'a>>) -> Self

Set the template of the span.

Source

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>

Source§

fn for_each<'kv, F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>>( &'kv self, for_each: F, ) -> ControlFlow<()>

Enumerate the Str and Value pairs. Read more
Source§

fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>
where K: ToStr,

Get the value for a given key, if it’s present. Read more
Source§

fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
where V: FromValue<'kv>, K: ToStr,

Get the value for a given key, if it’s present as an instance of V. Read more
Source§

fn is_unique(&self) -> bool

Whether the collection is known not to contain any duplicate keys. Read more
Source§

fn and_props<U>(self, other: U) -> And<Self, U>
where U: Props, Self: Sized,

Concatenate other to the end of self.
Source§

fn dedup(&self) -> &Dedup<Self>
where Self: Sized,

Lazily de-duplicate properties in the collection. Read more
Source§

impl<'a, P: Props> ToEvent for Span<'a, P>

Source§

type Props<'b> = &'b Span<'a, P> where Self: 'b

The kind of Props on the resulting value.
Source§

fn to_event<'b>(&'b self) -> Event<'b, Self::Props<'b>>

Perform the conversion.
Source§

impl<'a, P: Props> ToExtent for Span<'a, P>

Source§

fn to_extent(&self) -> Option<Extent>

Perform the conversion.

Auto Trait Implementations§

§

impl<'a, P> Freeze for Span<'a, P>
where P: Freeze,

§

impl<'a, P> RefUnwindSafe for Span<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for Span<'a, P>
where P: Send,

§

impl<'a, P> Sync for Span<'a, P>
where P: Sync,

§

impl<'a, P> Unpin for Span<'a, P>
where P: Unpin,

§

impl<'a, P> UnwindSafe for Span<'a, P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<P> ErasedProps for P
where P: Props,