-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): replace target column with kind column in tasks view (#…
…478) In the `tokio-console` tasks view, there are a fixed set of columns and any remaining fields are included in a "Fields" column at the end. One of the fields which is always present on a task, but doesn't receive a dedicated column is the kind field, which currently takes one of the following values: * `task` (a "normal" async task) * `blocking` * `block_on` * `local` Meanwhile, there is a dedicated column for the task span's target, which currently takes one of the following values: * `tokio::task` * `tokio::task::blocking` The target for tasks with kind `block_on` and `local` is also `tokio::task`. This change replaces the target column with a kind column as it provides more information in fewer characters. The target value is moved (somewhat artificially) to the fields which appear in the final column. The `target` is also left on the `state::Task` struct as we expect to want to filter by it in the future. Additionally, the `console-subscriber` examples have been updated so that there are options to visualize `blocking`, `block_on`, and `local` tasks. The `app` example has been updated to include an optional task which calls `tokio::spawn_blocking`. A new example `local` has been added which creates a `LocalSet` and spawns local tasks onto it.
- Loading branch information
Showing
6 changed files
with
116 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Local tasks | ||
//! | ||
//! This example shows the instrumentation on local tasks. Tasks spawned onto a | ||
//! `LocalSet` with `spawn_local` have the kind `local` in `tokio-console`. | ||
//! | ||
//! Additionally, because the `console-subscriber` is initialized before the | ||
//! tokio runtime is created, we will also see the `block_on` kind task. | ||
use std::time::Duration; | ||
use tokio::{runtime, task}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { | ||
console_subscriber::init(); | ||
|
||
let rt = runtime::Builder::new_current_thread() | ||
.enable_all() | ||
.build() | ||
.unwrap(); | ||
let local = task::LocalSet::new(); | ||
local.block_on(&rt, async { | ||
loop { | ||
let mut join_handles = Vec::new(); | ||
for _ in 0..10 { | ||
let jh = task::spawn_local(async { | ||
tokio::time::sleep(Duration::from_millis(100)).await; | ||
|
||
std::thread::sleep(Duration::from_millis(100)); | ||
}); | ||
join_handles.push(jh); | ||
} | ||
|
||
for jh in join_handles { | ||
_ = jh.await; | ||
} | ||
} | ||
}); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters