From 5da38fa16d221e5e6033fca0308444984d78f520 Mon Sep 17 00:00:00 2001 From: Luca Palmieri Date: Sun, 27 Sep 2020 16:41:22 +0100 Subject: [PATCH] Add request id --- Cargo.toml | 3 ++- src/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2c747b654..e2d355323 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tracing-actix-web" -version = "0.1.0" +version = "0.1.1" authors = ["Luca Palmieri "] 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"] } diff --git a/src/lib.rs b/src/lib.rs index a5c3b27b7..c9ba28fe7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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);