-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcompleting_task.rs
More file actions
35 lines (29 loc) · 1.2 KB
/
completing_task.rs
File metadata and controls
35 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use dial9_tokio_telemetry::task_dump::{DetectLongWait, LongPollTracker, SentinelStatus};
use tokio::time::Duration;
#[tokio::main]
async fn main() {
let (tracker, mut handle) = LongPollTracker::new();
tracker.spawn();
println!("Starting short sleep (2s) that completes before threshold...");
let sleep_future = tokio::time::sleep(Duration::from_secs(2));
let wrapped = DetectLongWait::new(sleep_future, handle.sentinel_tx.clone());
wrapped.await;
println!("Sleep completed successfully");
println!("Waiting 5 more seconds to see if any trace is sent...");
tokio::time::sleep(Duration::from_secs(5)).await;
if let Ok(event) = handle.rx.try_recv() {
println!("\n=== UNEXPECTED: TRACE RECEIVED ===");
println!(
"Status: {:?}",
match &event.status {
SentinelStatus::Pending(_) => "Pending",
SentinelStatus::Completed => "Completed",
SentinelStatus::Cancelled => "Cancelled",
}
);
println!("Send count: {}", event.send_count.0);
} else {
println!("\n✓ SUCCESS: No trace sent for task that completed before threshold");
}
std::process::exit(0);
}