Skip to content

Commit

Permalink
log add span_id
Browse files Browse the repository at this point in the history
  • Loading branch information
hongcha98 committed Feb 24, 2024
1 parent aebf904 commit ec19fe5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit ec19fe5

Please sign in to comment.