diff options
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/utils/exec.rs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index ebc18f11a05..209ff393973 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -572,6 +572,8 @@ enum CommandState<'a> { executed_at: &'a Location<'a>, fingerprint: CommandFingerprint, start_time: Instant, + #[cfg(feature = "tracing")] + _span_guard: tracing::span::EnteredSpan, }, } @@ -581,6 +583,8 @@ pub struct StreamingCommand { pub stderr: Option<ChildStderr>, fingerprint: CommandFingerprint, start_time: Instant, + #[cfg(feature = "tracing")] + _span_guard: tracing::span::EnteredSpan, } #[must_use] @@ -672,6 +676,9 @@ impl ExecutionContext { ) -> DeferredCommand<'a> { let fingerprint = command.fingerprint(); + #[cfg(feature = "tracing")] + let span_guard = trace_cmd!(command); + if let Some(cached_output) = self.command_cache.get(&fingerprint) { command.mark_as_executed(); self.verbose(|| println!("Cache hit: {command:?}")); @@ -692,13 +699,12 @@ impl ExecutionContext { executed_at, fingerprint, start_time: Instant::now(), + #[cfg(feature = "tracing")] + _span_guard: span_guard, }, }; } - #[cfg(feature = "tracing")] - let _run_span = trace_cmd!(command); - self.verbose(|| { println!("running: {command:?} (created at {created_at}, executed at {executed_at})") }); @@ -720,6 +726,8 @@ impl ExecutionContext { executed_at, fingerprint, start_time, + #[cfg(feature = "tracing")] + _span_guard: span_guard, }, } } @@ -773,6 +781,10 @@ impl ExecutionContext { if !command.run_in_dry_run && self.dry_run() { return None; } + + #[cfg(feature = "tracing")] + let span_guard = trace_cmd!(command); + let start_time = Instant::now(); let fingerprint = command.fingerprint(); let cmd = &mut command.command; @@ -786,7 +798,15 @@ impl ExecutionContext { let stdout = child.stdout.take(); let stderr = child.stderr.take(); - Some(StreamingCommand { child, stdout, stderr, fingerprint, start_time }) + Some(StreamingCommand { + child, + stdout, + stderr, + fingerprint, + start_time, + #[cfg(feature = "tracing")] + _span_guard: span_guard, + }) } } @@ -820,12 +840,17 @@ impl<'a> DeferredCommand<'a> { executed_at, fingerprint, start_time, + #[cfg(feature = "tracing")] + _span_guard, } => { let exec_ctx = exec_ctx.as_ref(); let output = Self::finish_process(process, command, stdout, stderr, executed_at, exec_ctx); + #[cfg(feature = "tracing")] + drop(_span_guard); + if (!exec_ctx.dry_run() || command.run_in_dry_run) && output.status().is_some() && command.should_cache |
