From cc78487fcb327ffd441ba0b2f8abeb8ffd78854f Mon Sep 17 00:00:00 2001 From: mdecimus Date: Tue, 3 Jun 2025 12:08:07 +0200 Subject: [PATCH] Include HTTP headers in logs --- crates/http-proto/src/request.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/http-proto/src/request.rs b/crates/http-proto/src/request.rs index 3d5fd697..da5d2538 100644 --- a/crates/http-proto/src/request.rs +++ b/crates/http-proto/src/request.rs @@ -6,6 +6,7 @@ use std::borrow::Cow; +use compact_str::ToCompactString; use http_body_util::BodyExt; use crate::HttpRequest; @@ -31,6 +32,14 @@ pub async fn fetch_body( trc::event!( Http(trc::HttpEvent::RequestBody), SpanId = session_id, + Details = req + .headers() + .iter() + .map(|(k, v)| trc::Value::Array(vec![ + k.as_str().to_compact_string().into(), + v.to_str().unwrap_or_default().to_compact_string().into() + ])) + .collect::>(), Contents = std::str::from_utf8(&bytes) .unwrap_or("[binary data]") .to_string(), @@ -46,6 +55,14 @@ pub async fn fetch_body( trc::event!( Http(trc::HttpEvent::RequestBody), SpanId = session_id, + Details = req + .headers() + .iter() + .map(|(k, v)| trc::Value::Array(vec![ + k.as_str().to_compact_string().into(), + v.to_str().unwrap_or_default().to_compact_string().into() + ])) + .collect::>(), Contents = std::str::from_utf8(&bytes) .unwrap_or("[binary data]") .to_string(),