diff options
Diffstat (limited to 'src/runtime/handle.rs')
-rw-r--r-- | src/runtime/handle.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/runtime/handle.rs b/src/runtime/handle.rs index b1e8d8f..72b9c06 100644 --- a/src/runtime/handle.rs +++ b/src/runtime/handle.rs @@ -39,13 +39,27 @@ impl Handle { // context::enter(self.clone(), f) // } - /// Run the provided function on an executor dedicated to blocking operations. + /// Run the provided function on an executor dedicated to blocking + /// operations. + #[cfg_attr(tokio_track_caller, track_caller)] pub(crate) fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R> where F: FnOnce() -> R + Send + 'static, + R: Send + 'static, { #[cfg(feature = "tracing")] let func = { + #[cfg(tokio_track_caller)] + let location = std::panic::Location::caller(); + #[cfg(tokio_track_caller)] + let span = tracing::trace_span!( + target: "tokio::task", + "task", + kind = %"blocking", + function = %std::any::type_name::<F>(), + spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()), + ); + #[cfg(not(tokio_track_caller))] let span = tracing::trace_span!( target: "tokio::task", "task", |