Struct MkSpanExecutor

pub struct MkSpanExecutor<E, F> { /* private fields */ }

An executor that uses a callback to propagate tracing span to its futures.

The callback is invoked each time a future is spawned, creating a span that will be entered each time that future is polled or dropped. Execution is delegated to the wrapped executor, without requiring a particular runtime.

Requires the tracing feature.

Example

Spawned tasks can be marked as "following from" the execution context.

See [tracing::Span::follows_from()] for more information about indicating causal relationships between spans.

# #[cfg(feature = "tokio")]
# {
use hyper_util::rt::{MkSpanExecutor, TokioExecutor};
use tracing::{info_span, Span};

let mk = || {
    let span = info_span!("example");
    span.follows_from(Span::current());
    span
};
let executor = MkSpanExecutor::new(TokioExecutor::new(), mk);
# }

Spawned tasks can be marked as children of the execution context.

# #[cfg(feature = "tokio")]
# {
use hyper_util::rt::{MkSpanExecutor, TokioExecutor};
use tracing::{info_span, Span};

let mk = || info_span!(parent: Span::current(), "example");
let executor = MkSpanExecutor::new(TokioExecutor::new(), mk);
# }

Implementations

impl<E, F> MkSpanExecutor<E, F>

fn new(inner: E, mk: F) -> Self

Wrap an executor that creates new spans to instrument spawned futures.

Trait Implementations

impl<E, F, Fut> Executor<Fut> for MkSpanExecutor<E, F> where E: Executor<Instrumented<Fut>>, F: Fn() -> Span, Fut: Future,

fn execute(&self, future: Fut)

impl<E: Clone, F: Clone> Clone for MkSpanExecutor<E, F>

fn clone(&self) -> Self

impl<E: Debug, F: Debug> Debug for MkSpanExecutor<E, F>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<E, F> Freeze for MkSpanExecutor<E, F> where E: Freeze, F: Freeze,

impl<E, F> RefUnwindSafe for MkSpanExecutor<E, F> where E: RefUnwindSafe, F: RefUnwindSafe,

impl<E, F> Send for MkSpanExecutor<E, F> where E: Send, F: Send,

impl<E, F> Sync for MkSpanExecutor<E, F> where E: Sync, F: Sync,

impl<E, F> Unpin for MkSpanExecutor<E, F> where E: Unpin, F: Unpin,

impl<E, F> UnsafeUnpin for MkSpanExecutor<E, F> where E: UnsafeUnpin, F: UnsafeUnpin,

impl<E, F> UnwindSafe for MkSpanExecutor<E, F> where E: UnwindSafe, F: UnwindSafe,

Blanket Implementations

impl<A, B, T> HttpServerConnExec<A, B> for MkSpanExecutor<E, F> where B: Body, T: Http2ServerConnExec<A, B>,

impl<E, B, T> Http2ClientConnExec<B, T> for MkSpanExecutor<E, F> where E: Clone + Executor<H2ClientFuture<B, T, E>> + Http2UpgradedExec<<B as Body>::Data>, B: Body + 'static, <B as Body>::Error: Into<Box<dyn Error + Sync + Send>>, H2ClientFuture<B, T, E>: Future<Output = ()>, T: Read + Write + Unpin,

fn execute_h2_future(&mut self, future: H2ClientFuture<B, T, E>)

impl<E, F, B> Http2ServerConnExec<F, B> for MkSpanExecutor<E, F> where E: Clone + Executor<H2Stream<F, B, E>> + Http2UpgradedExec<<B as Body>::Data>, H2Stream<F, B, E>: Future<Output = ()>, B: Body,

fn execute_h2stream(&mut self, fut: H2Stream<F, B, E>)

impl<T> Any for MkSpanExecutor<E, F> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for MkSpanExecutor<E, F> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for MkSpanExecutor<E, F> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for MkSpanExecutor<E, F> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for MkSpanExecutor<E, F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for MkSpanExecutor<E, F>

impl<T> ToOwned for MkSpanExecutor<E, F> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for MkSpanExecutor<E, F>

impl<T, U> Into<U> for MkSpanExecutor<E, F> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for MkSpanExecutor<E, F> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for MkSpanExecutor<E, F> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>