From 878ee1ee9d29527a53deabccc5189b4f7867c8d8 Mon Sep 17 00:00:00 2001 From: Hayden Stainsby Date: Wed, 22 Mar 2023 16:34:16 +0100 Subject: [PATCH] tracing: fix `spawn_blocking` location fields 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. --- tokio/src/runtime/blocking/pool.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index e9f6b66e0fc..a23b0a0d2de 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -371,7 +371,9 @@ impl Spawner { task.name = %name.unwrap_or_default(), task.id = id.as_u64(), "fn" = %std::any::type_name::(), - 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) };