-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): add task scheduled times histogram (#409)
Display the scheduled time percentiles and sparklines for the histogram of scheduled times. The schduled time is the time between when a task is woken and when it is next polled. The scheduled time, which was already calculated, is now stored in a histogram and sent over the wire in together with the task details. This is used to draw percentiles and sparklines on the task details view, in the same way that is done for the poll times histogram. The refactoring done in #408 has been used to more easily display two sets of durations (percentiles and histogram where possible). ## PR Notes The PR depends on both #406, which adds initial support for recording the scheduled (wake-to-poll) time, and #408, which refactors the percentile and histogram widgets to make them easier to reuse. It shouldn't really be reviewed in depth until those two have been merged as it contains a lot of duplication and will need to be rebased. Here are some examples of the scheduled times durations on the task detail view: <img width="1037" alt="task detail view for the sender task in the long-scheduled example" src="https://user-images.githubusercontent.com/89589/232608774-d8ac48a7-3fe7-4742-a75b-e11bdb23abaa.png"> <img width="1043" alt="task detail view for the burn task in the app example" src="https://user-images.githubusercontent.com/89589/232608864-637f4f52-d4a6-468d-88fc-8fe1d53fdff9.png">
- Loading branch information
Showing
12 changed files
with
239 additions
and
58 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
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,48 @@ | ||
use std::time::Duration; | ||
|
||
use console_subscriber::ConsoleLayer; | ||
use tokio::task::{self, yield_now}; | ||
use tracing::info; | ||
|
||
#[tokio::main(flavor = "multi_thread", worker_threads = 2)] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
ConsoleLayer::builder() | ||
.with_default_env() | ||
.publish_interval(Duration::from_millis(100)) | ||
.init(); | ||
|
||
let long_sleeps = task::Builder::new() | ||
.name("long-sleeps") | ||
.spawn(long_sleeps(5000)) | ||
.unwrap(); | ||
|
||
let sleep_forever = task::Builder::new() | ||
.name("sleep-forever") | ||
.spawn(sleep_forever(5000)) | ||
.unwrap(); | ||
|
||
match (long_sleeps.await, sleep_forever.await) { | ||
(Ok(_), Ok(_)) => info!("Success"), | ||
(_, _) => info!("Error awaiting tasks."), | ||
} | ||
|
||
tokio::time::sleep(Duration::from_millis(200)).await; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn long_sleeps(inc: u64) { | ||
let millis = inc; | ||
loop { | ||
std::thread::sleep(Duration::from_millis(millis)); | ||
|
||
yield_now().await; | ||
} | ||
} | ||
|
||
async fn sleep_forever(inc: u64) { | ||
let millis = inc; | ||
loop { | ||
std::thread::sleep(Duration::from_millis(millis)); | ||
} | ||
} |
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
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
Oops, something went wrong.