Skip to content

Commit

Permalink
task: fix spawn_local source location (#5984)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hds authored Sep 6, 2023
1 parent 8ea303e commit aad1892
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tokio/src/task/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ impl LocalSet {
run_until.await
}

#[track_caller]
pub(in crate::task) fn spawn_named<F>(
&self,
future: F,
Expand Down

0 comments on commit aad1892

Please sign in to comment.