@@ -29,7 +29,7 @@ use tokio::{
29
29
sync:: broadcast,
30
30
time:: { self , sleep, Duration } ,
31
31
} ;
32
- use tracing:: { debug, error, info, warn} ;
32
+ use tracing:: { debug, error, info, info_span , warn, Instrument } ;
33
33
use tracing_subscriber:: { fmt:: format:: FmtSpan , util:: SubscriberInitExt , EnvFilter } ;
34
34
35
35
#[ derive( thiserror:: Error , Debug ) ]
@@ -474,6 +474,8 @@ async fn inner_main(
474
474
}
475
475
}
476
476
477
+ let mut sequence_tgt_recv = tgt_snd. subscribe ( ) ;
478
+
477
479
let mut tsrv_joinset = tokio:: task:: JoinSet :: new ( ) ;
478
480
let mut osrv_joinset = tokio:: task:: JoinSet :: new ( ) ;
479
481
//
@@ -496,15 +498,23 @@ async fn inner_main(
496
498
} ;
497
499
498
500
let ( timer_watcher, timer_broadcast) = lading_signal:: signal ( ) ;
499
- tokio:: spawn ( async move {
500
- info ! ( "target is running, now sleeping for warmup" ) ;
501
- sleep ( warmup_duration) . await ;
502
- experiment_started_broadcast. signal ( ) ;
503
- info ! ( "warmup completed, collecting samples" ) ;
504
- sleep ( experiment_duration) . await ;
505
- info ! ( "experiment duration exceeded, signaling for shutdown" ) ;
506
- timer_broadcast. signal ( ) ;
507
- } ) ;
501
+
502
+ tokio:: spawn (
503
+ async move {
504
+ info ! ( "waiting for target startup" ) ;
505
+ if let Err ( e) = sequence_tgt_recv. recv ( ) . await {
506
+ warn ! ( "failed to wait: {:?}" , e) ;
507
+ }
508
+ info ! ( "target is running, now sleeping for warmup" ) ;
509
+ sleep ( warmup_duration) . await ;
510
+ experiment_started_broadcast. signal ( ) ;
511
+ info ! ( "warmup completed, collecting samples" ) ;
512
+ sleep ( experiment_duration) . await ;
513
+ info ! ( "experiment duration exceeded, signaling for shutdown" ) ;
514
+ timer_broadcast. signal ( ) ;
515
+ }
516
+ . instrument ( info_span ! ( "experiment_sequence" ) ) ,
517
+ ) ;
508
518
509
519
// We must be sure to drop any unused watcher at this point. Below in
510
520
// `signal_and_wait` if a watcher remains derived from `shutdown_watcher` the run will not shut down.
0 commit comments