tokio_trace::span

Struct Span

Source
pub struct Span { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl Span

Source

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

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.

Source

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

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.

Source

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

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.

Source

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

Constructs a new disabled span.

Source

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

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.

Source

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

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

Source

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

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

Source

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

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

Source

pub fn record_all(&self, values: &ValueSet<'_>) -> &Self

Visit all the fields in the span

Source

pub fn is_disabled(&self) -> bool

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

Source

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

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.

Source

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

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

Source

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

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

Trait Implementations§

Source§

impl<'a> AsId for &'a Span

Source§

fn as_id(&self) -> Option<&Id>

Returns the Id of the span that self corresponds to, or None if this corresponds to a disabled span.
Source§

impl AsId for Span

Source§

fn as_id(&self) -> Option<&Id>

Returns the Id of the span that self corresponds to, or None if this corresponds to a disabled span.
Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Span

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Span

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Span

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.