-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
Not Needed
-
hds has created PR #1201: track task spawn location for tokio instrumentation in mongo-rust-driver
Issue Text:
The tracing instrumentation present in tokio (which feeds into
tokio-console) tracks the spawning location of each task. This can be
useful in understanding what each task is doing, especially if the tasks
aren't named (which is a `tokio_unstable` feature so not usually present
in published crates).
The location tracking isn't as useful when tasks are spawned from some
central location like the `mongodb` crate does, because all tasks have
the same spawn location. However, since the instrumentation uses the
`panic:Location` to determine the spawn location, the `#[track_caller]`
attribute macro can be used to ensure that the actual location is picked
up instead of the common one.
A side effect of using the `#[track_caller]` attribute is that the
single line output in the case of a panic (when `RUST_BACKTRACE` isn't
set) will point to the callsite in the code, and not the common site -
although this is often desirable anyway.
This change adds `#[track_caller]` to the `pub(crate)` function
`crate::runtime::spawn` as well as the method `AsyncJoinHandle::spawn`.