1 cfg_trace! { 2 cfg_rt! { 3 pub(crate) use tracing::instrument::Instrumented; 4 5 #[inline] 6 #[cfg_attr(tokio_track_caller, track_caller)] 7 pub(crate) fn task<F>(task: F, kind: &'static str) -> Instrumented<F> { 8 use tracing::instrument::Instrument; 9 #[cfg(tokio_track_caller)] 10 let location = std::panic::Location::caller(); 11 #[cfg(tokio_track_caller)] 12 let span = tracing::trace_span!( 13 target: "tokio::task", 14 "task", 15 %kind, 16 spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()), 17 ); 18 #[cfg(not(tokio_track_caller))] 19 let span = tracing::trace_span!( 20 target: "tokio::task", 21 "task", 22 %kind, 23 ); 24 task.instrument(span) 25 } 26 } 27 } 28 29 cfg_not_trace! { 30 cfg_rt! { 31 #[inline] 32 pub(crate) fn task<F>(task: F, _: &'static str) -> F { 33 // nop 34 task 35 } 36 } 37 } 38