# tracing::instrument::WithSubscriber - Rust
API documentation for the Rust `WithSubscriber` trait in crate `tracing`.
Keywords: rust, rustlang, rust-lang, WithSubscriber

# Trait tracing::instrument::WithSubscriber [−] [src]

    pub trait WithSubscriber: Sized {
        fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
        where
            S: Into<Dispatch>,
        { ... }
        fn with_current_subscriber(self) -> WithDispatch<Self> { ... }
    }

Extension trait allowing futures to be instrumented with a `tracing` `Subscriber`.

## Provided methods

### `fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,` [src]

Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper.

The attached subscriber will be set as the default when the returned `Future` is polled.

### `fn with_current_subscriber(self) -> WithDispatch<Self>` [src]

Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper.

When the wrapped type is a future, stream, or sink, the attached subscriber will be set as the default while it is being polled. When the wrapped type is an executor, the subscriber will be set as the default for any futures spawned on that executor.

This can be used to propagate the current dispatcher context when spawning a new future.

Loading content...

## Implementors

Loading content...