pub struct Ctx { /* private fields */ }Expand description
A captured trace scope: a tracer plus the current span id.
Get one with current() and re-enter it in a spawned task or a
blocking closure with enter or in_scope, so parents stay right.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
Runs f with this scope current on this thread, restoring the
previous scope afterwards, also when f panics.
Input: the closure. Output: its result.
Sourcepub fn in_scope<F: Future>(&self, fut: F) -> Instrumented<F> ⓘ
pub fn in_scope<F: Future>(&self, fut: F) -> Instrumented<F> ⓘ
Wraps fut so this scope is current on every poll.
Input: the future. Output: the wrapped future.
Sourcepub fn nest(&self, categories: TraceSet, content: Option<bool>) -> Ctx
pub fn nest(&self, categories: TraceSet, content: Option<bool>) -> Ctx
Returns a scope in the same trace and sink with categories added.
content replaces this scope’s content flag when given.
Input: extra categories and an optional flag. Output: the nested scope.
Sourcepub fn span_id(&self) -> u64
pub fn span_id(&self) -> u64
Returns the current span id, 0 at the root. Input: none. Output: the id.
Sourcepub fn categories(&self) -> TraceSet
pub fn categories(&self) -> TraceSet
Returns the categories of this scope. Input: none. Output: the set.