1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-22 18:33:18 +01:00

Add request id

This commit is contained in:
Luca Palmieri 2020-09-27 16:41:22 +01:00
parent 4ef6f95608
commit 5da38fa16d
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "tracing-actix-web"
version = "0.1.0"
version = "0.1.1"
authors = ["Luca Palmieri <rust@lpalmieri.com>"]
edition = "2018"
@ -20,6 +20,7 @@ actix-web = "2"
tracing = "0.1.19"
tracing-futures = "0.2.4"
futures = "0.3.5"
uuid = { version = "0.8.1", features = ["v4"] }
[dev-dependencies]
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] }

View File

@ -23,6 +23,7 @@ use std::future::Future;
use std::pin::Pin;
use tracing::Span;
use tracing_futures::Instrument;
use uuid::Uuid;
/// `TracingLogger` is a middleware to log request and response info in a structured format.
///
@ -136,6 +137,7 @@ where
request_path = %req.path(),
user_agent = %user_agent,
client_ip_address = %req.connection_info().remote().unwrap_or(""),
request_id = %Uuid::new_v4(),
status_code = tracing::field::Empty,
);
let fut = self.service.call(req);