@@ -593,6 +593,8 @@ enum CommandState<'a> {
593
593
executed_at : & ' a Location < ' a > ,
594
594
fingerprint : CommandFingerprint ,
595
595
start_time : Instant ,
596
+ #[ cfg( feature = "tracing" ) ]
597
+ _span_guard : tracing:: span:: EnteredSpan ,
596
598
} ,
597
599
}
598
600
@@ -602,6 +604,8 @@ pub struct StreamingCommand {
602
604
pub stderr : Option < ChildStderr > ,
603
605
fingerprint : CommandFingerprint ,
604
606
start_time : Instant ,
607
+ #[ cfg( feature = "tracing" ) ]
608
+ _span_guard : tracing:: span:: EnteredSpan ,
605
609
}
606
610
607
611
#[ must_use]
@@ -693,6 +697,9 @@ impl ExecutionContext {
693
697
) -> DeferredCommand < ' a > {
694
698
let fingerprint = command. fingerprint ( ) ;
695
699
700
+ #[ cfg( feature = "tracing" ) ]
701
+ let span_guard = trace_cmd ! ( command) ;
702
+
696
703
if let Some ( cached_output) = self . command_cache . get ( & fingerprint) {
697
704
command. mark_as_executed ( ) ;
698
705
self . verbose ( || println ! ( "Cache hit: {command:?}" ) ) ;
@@ -713,13 +720,12 @@ impl ExecutionContext {
713
720
executed_at,
714
721
fingerprint,
715
722
start_time : Instant :: now ( ) ,
723
+ #[ cfg( feature = "tracing" ) ]
724
+ _span_guard : span_guard,
716
725
} ,
717
726
} ;
718
727
}
719
728
720
- #[ cfg( feature = "tracing" ) ]
721
- let _run_span = trace_cmd ! ( command) ;
722
-
723
729
self . verbose ( || {
724
730
println ! ( "running: {command:?} (created at {created_at}, executed at {executed_at})" )
725
731
} ) ;
@@ -741,6 +747,8 @@ impl ExecutionContext {
741
747
executed_at,
742
748
fingerprint,
743
749
start_time,
750
+ #[ cfg( feature = "tracing" ) ]
751
+ _span_guard : span_guard,
744
752
} ,
745
753
}
746
754
}
@@ -794,6 +802,10 @@ impl ExecutionContext {
794
802
if !command. run_in_dry_run && self . dry_run ( ) {
795
803
return None ;
796
804
}
805
+
806
+ #[ cfg( feature = "tracing" ) ]
807
+ let span_guard = trace_cmd ! ( command) ;
808
+
797
809
let start_time = Instant :: now ( ) ;
798
810
let fingerprint = command. fingerprint ( ) ;
799
811
let cmd = & mut command. command ;
@@ -807,7 +819,15 @@ impl ExecutionContext {
807
819
808
820
let stdout = child. stdout . take ( ) ;
809
821
let stderr = child. stderr . take ( ) ;
810
- Some ( StreamingCommand { child, stdout, stderr, fingerprint, start_time } )
822
+ Some ( StreamingCommand {
823
+ child,
824
+ stdout,
825
+ stderr,
826
+ fingerprint,
827
+ start_time,
828
+ #[ cfg( feature = "tracing" ) ]
829
+ _span_guard : span_guard,
830
+ } )
811
831
}
812
832
}
813
833
@@ -841,12 +861,17 @@ impl<'a> DeferredCommand<'a> {
841
861
executed_at,
842
862
fingerprint,
843
863
start_time,
864
+ #[ cfg( feature = "tracing") ]
865
+ _span_guard,
844
866
} => {
845
867
let exec_ctx = exec_ctx. as_ref ( ) ;
846
868
847
869
let output =
848
870
Self :: finish_process ( process, command, stdout, stderr, executed_at, exec_ctx) ;
849
871
872
+ #[ cfg( feature = "tracing" ) ]
873
+ drop ( _span_guard) ;
874
+
850
875
if ( !exec_ctx. dry_run ( ) || command. run_in_dry_run )
851
876
&& output. status ( ) . is_some ( )
852
877
&& command. should_cache
0 commit comments