@@ -572,6 +572,8 @@ enum CommandState<'a> {
572
572
executed_at : & ' a Location < ' a > ,
573
573
fingerprint : CommandFingerprint ,
574
574
start_time : Instant ,
575
+ #[ cfg( feature = "tracing" ) ]
576
+ _span_guard : tracing:: span:: EnteredSpan ,
575
577
} ,
576
578
}
577
579
@@ -581,6 +583,8 @@ pub struct StreamingCommand {
581
583
pub stderr : Option < ChildStderr > ,
582
584
fingerprint : CommandFingerprint ,
583
585
start_time : Instant ,
586
+ #[ cfg( feature = "tracing" ) ]
587
+ _span_guard : tracing:: span:: EnteredSpan ,
584
588
}
585
589
586
590
#[ must_use]
@@ -672,6 +676,9 @@ impl ExecutionContext {
672
676
) -> DeferredCommand < ' a > {
673
677
let fingerprint = command. fingerprint ( ) ;
674
678
679
+ #[ cfg( feature = "tracing" ) ]
680
+ let span_guard = trace_cmd ! ( command) ;
681
+
675
682
if let Some ( cached_output) = self . command_cache . get ( & fingerprint) {
676
683
command. mark_as_executed ( ) ;
677
684
self . verbose ( || println ! ( "Cache hit: {command:?}" ) ) ;
@@ -692,13 +699,12 @@ impl ExecutionContext {
692
699
executed_at,
693
700
fingerprint,
694
701
start_time : Instant :: now ( ) ,
702
+ #[ cfg( feature = "tracing" ) ]
703
+ _span_guard : span_guard,
695
704
} ,
696
705
} ;
697
706
}
698
707
699
- #[ cfg( feature = "tracing" ) ]
700
- let _run_span = trace_cmd ! ( command) ;
701
-
702
708
self . verbose ( || {
703
709
println ! ( "running: {command:?} (created at {created_at}, executed at {executed_at})" )
704
710
} ) ;
@@ -720,6 +726,8 @@ impl ExecutionContext {
720
726
executed_at,
721
727
fingerprint,
722
728
start_time,
729
+ #[ cfg( feature = "tracing" ) ]
730
+ _span_guard : span_guard,
723
731
} ,
724
732
}
725
733
}
@@ -773,6 +781,10 @@ impl ExecutionContext {
773
781
if !command. run_in_dry_run && self . dry_run ( ) {
774
782
return None ;
775
783
}
784
+
785
+ #[ cfg( feature = "tracing" ) ]
786
+ let span_guard = trace_cmd ! ( command) ;
787
+
776
788
let start_time = Instant :: now ( ) ;
777
789
let fingerprint = command. fingerprint ( ) ;
778
790
let cmd = & mut command. command ;
@@ -786,7 +798,15 @@ impl ExecutionContext {
786
798
787
799
let stdout = child. stdout . take ( ) ;
788
800
let stderr = child. stderr . take ( ) ;
789
- Some ( StreamingCommand { child, stdout, stderr, fingerprint, start_time } )
801
+ Some ( StreamingCommand {
802
+ child,
803
+ stdout,
804
+ stderr,
805
+ fingerprint,
806
+ start_time,
807
+ #[ cfg( feature = "tracing" ) ]
808
+ _span_guard : span_guard,
809
+ } )
790
810
}
791
811
}
792
812
@@ -820,12 +840,17 @@ impl<'a> DeferredCommand<'a> {
820
840
executed_at,
821
841
fingerprint,
822
842
start_time,
843
+ #[ cfg( feature = "tracing") ]
844
+ _span_guard,
823
845
} => {
824
846
let exec_ctx = exec_ctx. as_ref ( ) ;
825
847
826
848
let output =
827
849
Self :: finish_process ( process, command, stdout, stderr, executed_at, exec_ctx) ;
828
850
851
+ #[ cfg( feature = "tracing" ) ]
852
+ drop ( _span_guard) ;
853
+
829
854
if ( !exec_ctx. dry_run ( ) || command. run_in_dry_run )
830
855
&& output. status ( ) . is_some ( )
831
856
&& command. should_cache
0 commit comments