Skip to main content

Span

Struct Span 

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

A span guard: writes a start record when opened and an end record when dropped. A span opened outside any scope, or for a category that is off, is disabled and every method on it does nothing.

Implementations§

Source§

impl Span

Source

pub fn none() -> Span

Returns a disabled span. Input: none. Output: a span that records nothing.

Source

pub fn is_enabled(&self) -> bool

Returns whether this span records. Input: none. Output: the flag.

Source

pub fn id(&self) -> u64

Returns the span id, or 0 when disabled. Input: none. Output: the id.

Source

pub fn record(&mut self, key: &str, value: impl Into<Value>)

Adds a field written in the end record. Input: the key and value. Output: none.

Source

pub fn fail(&mut self, msg: impl Into<String>)

Marks the span failed with msg; the end record has ok: false. Input: the error text. Output: none.

Source

pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R

Runs f with this span as the current parent on this thread. Input: the closure. Output: its result.

Source

pub fn instrument<F: Future>(&self, fut: F) -> impl Future<Output = F::Output>

Wraps fut so this span is the current parent on every poll. A disabled span leaves the caller’s scope as it is. Nothing is boxed: the future is pinned inside the returned future.

Trait Implementations§

Source§

impl Drop for Span

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Span

§

impl !UnwindSafe for Span

§

impl Forget for Span

§

impl Freeze for Span
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const u8 is !null: Freeze, PhantomData<(String, Value)>: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Span

§

impl Send for Span
where Arc<Inner>: Send, RawVecInner: Send,

§

impl Sync for Span
where Arc<Inner>: Sync, RawVecInner: Sync,

§

impl Unpin for Span
where Arc<Inner>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Span
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<(String, Value)>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.