From ec19fe5125909e8dc499aa5d9f7aaad9241923d8 Mon Sep 17 00:00:00 2001 From: hongcha Date: Sat, 24 Feb 2024 21:48:27 +0800 Subject: [PATCH] log add span_id --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f0c9169f..93dfc33a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,11 +96,14 @@ async fn main() { .layer(axum::middleware::from_fn(print_request_response)) .layer( TraceLayer::new_for_http().make_span_with(|request: &Request<_>| { - info_span!( + let span = info_span!( "http_request", uri = ?request.uri(), method = ?request.method(), - ) + span_id = tracing::field::Empty, + ); + span.record("span_id", span.id().unwrap().into_u64()); + span }), ); tokio::select! {