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
impl Span
Sourcepub fn none() -> Span
pub fn none() -> Span
Returns a disabled span. Input: none. Output: a span that records nothing.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns whether this span records. Input: none. Output: the flag.
Sourcepub fn record(&mut self, key: &str, value: impl Into<Value>)
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.
Sourcepub fn fail(&mut self, msg: impl Into<String>)
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.
Sourcepub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
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.
Sourcepub fn instrument<F: Future>(&self, fut: F) -> impl Future<Output = F::Output>
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.