actix_tracing

# Function trace

source

    pub fn trace<S, Req, I, F>(
        service_factory: I,
        make_span: F,
    ) -> ApplyTransform<TracingTransform<S::Service, S, F>, S, Req>where
        I: IntoServiceFactory<S, Req>,
        S: ServiceFactory<Req>,
        F: Fn(&Req) -> Option<Span> + Clone,

Expand description

Wraps the provided service factory with a transform that automatically enters/exits the given span.

The span to be entered/exited can be provided via a closure. The closure is passed in a reference to the request being handled by the service.

For example:

ⓘ

    let traced_service = trace(
        web_service,
        |req: &Request| Some(span!(Level::INFO, "request", req.id))
    );