Skip to content

Commit aad1892

Browse files
authored
task: fix spawn_local source location (#5984)
The location of a spawned task, as shown in tokio console, is taken from the location set on the tracing span that instruments the task. For this location to work, there must be unbroken chain of functions instrumented with `#[track_caller]`. For `task::spawn_local`, there was a break in this chain and so the span contained the location of an internal function in tokio. This change adds the missing `#[track_caller]` attribute. It has been tested locally as automated tests would really need `tracing-mock` to be published so we can use it in the tokio tests.
1 parent 8ea303e commit aad1892

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tokio/src/task/local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ impl LocalSet {
575575
run_until.await
576576
}
577577

578+
#[track_caller]
578579
pub(in crate::task) fn spawn_named<F>(
579580
&self,
580581
future: F,

0 commit comments

Comments
 (0)