From c761a1810ab2a8b0f6025582ead3564072acc08a Mon Sep 17 00:00:00 2001 From: Maxime Guerreiro Date: Mon, 11 May 2026 00:58:17 +0200 Subject: [PATCH] chore(rt): preserve executor caller locations Tokio task hooks report the source location of the tokio::spawn call. When hyper-util's executor glue performs that spawn, the recorded location points at the executor implementation itself. That is technically correct, but it hides the more useful callsite: the code path in Hyper or hyper-util that asked the executor to create background work. Mark the executor forwarding methods with track_caller so task instrumentation can attribute spawned tasks to the caller that requested execution rather than to the generic executor glue. --- src/common/exec.rs | 2 ++ src/rt/tokio.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/common/exec.rs b/src/common/exec.rs index 40860ee..4cc9c46 100644 --- a/src/common/exec.rs +++ b/src/common/exec.rs @@ -25,6 +25,7 @@ impl Exec { Exec::Executor(Arc::new(inner)) } + #[track_caller] pub(crate) fn execute(&self, fut: F) where F: Future + Send + 'static, @@ -47,6 +48,7 @@ impl hyper::rt::Executor for Exec where F: Future + Send + 'static, { + #[track_caller] fn execute(&self, fut: F) { Exec::execute(self, fut); } diff --git a/src/rt/tokio.rs b/src/rt/tokio.rs index bd5fd50..ae04a7b 100644 --- a/src/rt/tokio.rs +++ b/src/rt/tokio.rs @@ -107,6 +107,7 @@ where Fut: Future + Send + 'static, Fut::Output: Send + 'static, { + #[track_caller] fn execute(&self, fut: Fut) { #[cfg(feature = "tracing")] tokio::spawn(fut.in_current_span());