From 7ad03f824c19352023960730c32163def90e8b39 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 5 Jan 2024 12:17:31 +0100 Subject: [PATCH] Fix `tracing` instrumentation across `spawn_blocking()` calls (#7878) --- src/tasks.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tasks.rs b/src/tasks.rs index 93c7f1c60a0..8598e002e03 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -15,8 +15,9 @@ where R: Send + 'static, E: Send + From + 'static, { + let current_span = tracing::Span::current(); let hub = Hub::current(); - tokio::task::spawn_blocking(move || Hub::run(hub, f)) + tokio::task::spawn_blocking(move || current_span.in_scope(|| Hub::run(hub, f))) .await // Convert `JoinError` to `E` .map_err(Into::into)