From f809b04782995d2fbb62f64e704ad4765cd14469 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 8 Sep 2026 14:02:13 +0800 Subject: [PATCH] fix(inbound): scope the tracing span guard in the TCP accept path The entered span guard was held across the await of the connection handler, so the span stayed entered on the thread while the task yielded and unrelated tasks were attributed to it. The span variable was also shadowed right after the guard was taken. Scope the guard to the debug log and keep a single span. --- leaf/src/app/inbound/network_listener.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/leaf/src/app/inbound/network_listener.rs b/leaf/src/app/inbound/network_listener.rs index 9a8c958..ae005c8 100644 --- a/leaf/src/app/inbound/network_listener.rs +++ b/leaf/src/app/inbound/network_listener.rs @@ -187,12 +187,13 @@ async fn handle_inbound_tcp_stream( ..Default::default() }; let span = sess.span(); - let _g = span.enter(); - let span = sess.span(); - debug!( - "handle inbound tcp stream src={} local={}", - &source, &local_addr - ); + { + let _g = span.enter(); + debug!( + "handle inbound tcp stream src={} local={}", + &source, &local_addr + ); + } async move { // Transforms the TCP stream into an inbound transport. let transport = timeout(