From 36e5ddb0f2463a175c04b990451a396f0028d86c Mon Sep 17 00:00:00 2001 From: leaysgur <6259812+leaysgur@users.noreply.github.com> Date: Tue, 27 Oct 2026 09:25:14 +0000 Subject: [PATCH] feat(oxfmt): add debug span for reading files (#28204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading a file happens outside the `oxfmt::format` span, so time spent in I/O did not show up with `OXC_LOG=debug`. On a machine where an endpoint security agent scans every `open()`/`close()`, most of the wall time was spent there, but the log only showed formatting time. ``` DEBUG oxfmt::read{path=src/foo.tsx}: oxfmt::cli::service: close time.busy=92.6µs time.idle=2.38µs ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- apps/oxfmt/src/cli/service.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/oxfmt/src/cli/service.rs b/apps/oxfmt/src/cli/service.rs index 15204281aa..cf302c62a7 100644 --- a/apps/oxfmt/src/cli/service.rs +++ b/apps/oxfmt/src/cli/service.rs @@ -7,6 +7,7 @@ use std::{ use cow_utils::CowUtils; use rayon::prelude::*; +use tracing::debug_span; use oxc_diagnostics::{DiagnosticSender, DiagnosticService}; @@ -44,7 +45,9 @@ impl FormatService { let start_time = matches!(self.format_mode, OutputMode::Check).then(Instant::now); let path = Arc::clone(&plan.path); - let Ok(source_text) = utils::read_to_string(&path) else { + let Ok(source_text) = debug_span!("oxfmt::read", path = %path.display()) + .in_scope(|| utils::read_to_string(&path)) + else { // This happens if binary file is attempted to be formatted // e.g. `.ts` for MPEG-TS video file let diagnostics = DiagnosticService::wrap_diagnostics(