feat(oxfmt): add debug span for reading files (#28204)

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)
This commit is contained in:
leaysgur committed 2026-10-27 09:25:14 +00:00
1 parent f00862bbf3
commit 36e5ddb0f2
1 file changed
+4 -1
+4 -1
View File
@@ -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(