Struct tracing_subscriber::layer::Context [−][src]
Represents information about the current context provided to Layer
s by the
wrapped Subscriber
.
To access stored data keyed by a span ID, implementors of the Layer
trait should ensure that the Subscriber
type parameter is also bound by the
LookupSpan
:
use tracing::Subscriber; use tracing_subscriber::{Layer, registry::LookupSpan}; pub struct MyLayer; impl<S> Layer<S> for MyLayer where S: Subscriber + for<'a> LookupSpan<'a>, { // ... }
Implementations
impl<'a, S> Context<'a, S> where
S: Subscriber,
[src]
S: Subscriber,
pub fn current_span(&self) -> Current
[src]
Returns the wrapped subscriber’s view of the current span.
pub fn enabled(&self, metadata: &Metadata<'_>) -> bool
[src]
Returns whether the wrapped subscriber would enable the current span.
pub fn event(&self, event: &Event<'_>)
[src]
Records the provided event
with the wrapped subscriber.
Notes
- The subscriber is free to expect that the event’s callsite has been
registered, and may panic or fail to observe the event if this is
not the case. The
tracing
crate’s macros ensure that all events are registered, but if the event is constructed through other means, the user is responsible for ensuring thatregister_callsite
has been called prior to calling this method. - This does not call
enabled
on the inner subscriber. If the caller wishes to apply the wrapped subscriber’s filter before choosing whether to record the event, it may first callContext::enabled
to check whether the event would be enabled. This allowsLayer
s to elide constructing the event if it would not be recorded.
pub fn metadata(&self, id: &Id) -> Option<&'static Metadata<'static>> where
S: for<'lookup> LookupSpan<'lookup>,
[src]
S: for<'lookup> LookupSpan<'lookup>,
Returns metadata for the span with the given id
, if it exists.
If this returns None
, then no span exists for that ID (either it has
closed or the ID is invalid).
pub fn span(&self, id: &Id) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
[src]
S: for<'lookup> LookupSpan<'lookup>,
Returns stored data for the span with the given id
, if it exists.
If this returns None
, then no span exists for that ID (either it has
closed or the ID is invalid).
Note: This requires the wrapped subscriber to implement theLookupSpan
trait. See the documentation onContext
's declaration for details.
pub fn exists(&self, id: &Id) -> bool where
S: for<'lookup> LookupSpan<'lookup>,
[src]
S: for<'lookup> LookupSpan<'lookup>,
Returns true
if an active span exists for the given Id
.
Note: This requires the wrapped subscriber to implement theLookupSpan
trait. See the documentation onContext
's declaration for details.
pub fn lookup_current(&self) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
[src]
S: for<'lookup> LookupSpan<'lookup>,
Returns stored data for the span that the wrapped subscriber considers to be the current.
If this returns None
, then we are not currently within a span.
Note: This requires the wrapped subscriber to implement theLookupSpan
trait. See the documentation onContext
's declaration for details.
pub fn scope(&self) -> Scope<'_, S>ⓘ where
S: for<'lookup> LookupSpan<'lookup>,
[src]
S: for<'lookup> LookupSpan<'lookup>,
Returns an iterator over the stored data for all the spans in the current context, starting the root of the trace tree and ending with the current span.
If this iterator is empty, then there are no spans in the current context.
Note: This requires the wrapped subscriber to implement theLookupSpan
trait. See the documentation onContext
's declaration for details.
Trait Implementations
impl<'a, S> Clone for Context<'a, S>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, S: Debug> Debug for Context<'a, S>
[src]
Auto Trait Implementations
impl<'a, S> RefUnwindSafe for Context<'a, S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<'a, S> Send for Context<'a, S> where
S: Sync,
S: Sync,
impl<'a, S> Sync for Context<'a, S> where
S: Sync,
S: Sync,
impl<'a, S> Unpin for Context<'a, S>
impl<'a, S> UnwindSafe for Context<'a, S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,