From 221bb94b9c78f137cb0675f62b6d2e26cdf8d987 Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 13 Apr 2022 16:27:58 +0100 Subject: [PATCH] blocking: `#[track_caller]` for spawn_blocking (#4616) Annotates spawn_blocking() with #[track_caller] in order to produce the correct tracing span spawn locations that show the caller as the spawn point. --- tokio/src/runtime/blocking/pool.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index ef3662390..e47073ce2 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -104,6 +104,7 @@ const KEEP_ALIVE: Duration = Duration::from_secs(10); /// Runs the provided function on an executor dedicated to blocking operations. /// Tasks will be scheduled as non-mandatory, meaning they may not get executed /// in case of runtime shutdown. +#[track_caller] pub(crate) fn spawn_blocking(func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static,