tracing-actix-web2

Crates.iotracing-actix-web2
lib.rstracing-actix-web2
version2.0.0
sourcesrc
created_at2021-05-15 15:58:56.206019
updated_at2022-03-14 09:33:01.355074
descriptionRust tracing adapter for Actix Web
homepagehttps://github.com/oscartbeaumont/tracing-actix-web
repositoryhttps://github.com/oscartbeaumont/tracing-actix-web
max_upload_size
id397906
size7,762
Oscar Beaumont (oscartbeaumont)

documentation

https://docs.rs/tracing-actix-web2

README

tracing-actix-web2

Rust tracing adapter for Actix Web

Crates.io version Download docs.rs docs

This crate aims to bridge tracing and actix-web by automatically populating data from the HttpRequest in the tracing span.

This crate is an alternative to tracing_actix_web and was created to add the following two features.

Request Logging

This crate will log every request made to the HTTP server. These logs are only be visible if the log level is set to trace. This can be done by setting the RUST_LOG environment varible to tracing_actix_web2=trace.

X-Request-ID Header

This crate will generate a UUID for each HTTP request and include it in the span along with the X-Request-ID HTTP header.

Install

Add tracing-actix-web2 to your dependencies:

[dependencies]
# ...
actix-web = "3.3.2"
tracing-actix-web2 = "1.0.0"

Usage

use actix_web::{App, web, HttpServer};
use tracing_actix_web2::Tracer;

fn main() {
    // Init your `tracing` subscriber here!

    let server = HttpServer::new(|| {
        App::new()
            // Mount `Tracer` as a middleware
            .wrap(Tracer)
            .service( /*  */ )
    });
}

For a full example check out this example application.

Commit count: 0

cargo fmt