Skip to content

Commit

Permalink
tracing: fix spawn_blocking location fields
Browse files Browse the repository at this point in the history
In a previous PR (#4128), the `spawn.location` field on task spans was
structured into 3 separate fields for the `file`, `line`, and `col`.
There is a separately created span for blocking tasks which was missed.

This caused tasks created with `spawn_blocking` to appear in
`tokio-console` without a location, but with an additional "free form"
field containing the formatted source code location.

This change modifies this span to use the same format. The span creation
needs to be separate from the other task spans because it records the
function name. This information is useful in the `spawn_blocking` case,
but can be "catastrophically long" in the `async fn` case and was
removed in #3074.
  • Loading branch information
hds committed Mar 22, 2023
1 parent a7bb054 commit 878ee1e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tokio/src/runtime/blocking/pool.rs
Expand Up @@ -371,7 +371,9 @@ impl Spawner {
task.name = %name.unwrap_or_default(),
task.id = id.as_u64(),
"fn" = %std::any::type_name::<F>(),
spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()),
loc.file = location.file(),
loc.line = location.line(),
loc.col = location.column(),
);
fut.instrument(span)
};
Expand Down

0 comments on commit 878ee1e

Please sign in to comment.