[][src]Struct tokio_trace::span::Span

pub struct Span { /* fields omitted */ }

A handle representing a span, with the capability to enter the span if it exists.

If the span was rejected by the current Subscriber's filter, entering the span will silently do nothing. Thus, the handle can be used in the same manner regardless of whether or not the trace is currently being collected.

Methods

impl Span[src]

pub fn new(meta: &'static Metadata<'static>, values: &ValueSet) -> Span[src]

Constructs a new Span with the given metadata and set of field values.

The new span will be constructed by the currently-active Subscriber, with the current span as its parent (if one exists).

After the span is constructed, field values and/or follows_from annotations may be added to it.

pub fn new_root(meta: &'static Metadata<'static>, values: &ValueSet) -> Span[src]

Constructs a new Span as the root of its own trace tree, with the given metadata and set of field values.

After the span is constructed, field values and/or follows_from annotations may be added to it.

pub fn child_of<I>(
    parent: I,
    meta: &'static Metadata<'static>,
    values: &ValueSet
) -> Span where
    I: AsId
[src]

Constructs a new Span as child of the given parent span, with the given metadata and set of field values.

After the span is constructed, field values and/or follows_from annotations may be added to it.

pub fn new_disabled(meta: &'static Metadata<'static>) -> Span[src]

Constructs a new disabled span.

pub fn enter<F: FnOnce() -> T, T>(&self, f: F) -> T[src]

Executes the given function in the context of this span.

If this span is enabled, then this function enters the span, invokes and then exits the span. If the span is disabled, f will still be invoked, but in the context of the currently-executing span (if there is one).

Returns the result of evaluating f.

pub fn field<Q: ?Sized>(&self, field: &Q) -> Option<Field> where
    Q: AsField
[src]

Returns a Field for the field with the given name, if one exists,

pub fn has_field<Q: ?Sized>(&self, field: &Q) -> bool where
    Q: AsField
[src]

Returns true if this Span has a field for the given Field or field name.

pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self where
    Q: AsField,
    V: Value
[src]

Visits that the field described by field has the value value.

pub fn record_all(&self, values: &ValueSet) -> &Self[src]

Visit all the fields in the span

pub fn is_disabled(&self) -> bool[src]

Returns true if this span was disabled by the subscriber and does not exist.

pub fn follows_from<I>(&self, from: I) -> &Self where
    I: AsId
[src]

Indicates that the span with the given ID has an indirect causal relationship with this span.

This relationship differs somewhat from the parent-child relationship: a span may have any number of prior spans, rather than a single one; and spans are not considered to be executing inside of the spans they follow from. This means that a span may close even if subsequent spans that follow from it are still open, and time spent inside of a subsequent span should not be included in the time its precedents were executing. This is used to model causal relationships such as when a single future spawns several related background tasks, et cetera.

If this span is disabled, or the resulting follows-from relationship would be invalid, this function will do nothing.

pub fn id(&self) -> Option<Id>[src]

Returns this span's Id, if it is enabled.

pub fn metadata(&self) -> Option<&'static Metadata<'static>>[src]

Returns this span's Metadata, if it is enabled.

Trait Implementations

impl AsId for Span[src]

impl<'a> AsId for &'a Span[src]

impl PartialEq<Span> for Span[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Clone for Span[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Span[src]

impl Hash for Span[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for Span

impl Sync for Span

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.