Skip to content

fs: add per-operation fs diagnostics channels - #65370

Draft
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fs-diagnostics-channel
Draft

fs: add per-operation fs diagnostics channels#65370
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fs-diagnostics-channel

Conversation

@mcollina

@mcollina mcollina commented Aug 18, 2026

Copy link
Copy Markdown
Member

Adds built-in node:diagnostics_channel channels for file system operations performed through node:fs and node:fs/promises, addressing #65330.

Each operation gets its own TracingChannel family named fs.<operation> (e.g. fs.open, fs.read, fs.stat), with channels tracing:fs.<operation>:start, :end, :asyncStart, :asyncEnd, and :error. The event payload carries the API (sync/callback/promise), path/dest/fd fields when applicable, plus result/error following TracingChannel conventions. Subscribers can use diagnostics_channel.tracingChannel('fs.open') to subscribe to all events of one operation at once, or subscribe to individual channels by name.

Events are published from the internal shared file system layer rather than the JS wrappers, so captured function references still emit events. Adds documentation and a new test/parallel/test-diagnostics-channel-fs.js.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 18, 2026
@mcollina

Copy link
Copy Markdown
Member Author

@nodejs/diagnostics wdyt? Should we do this or should we have one event for each operation?

Comment thread src/node_file.cc
if (!path.empty()) {
obj->Set(context,
env->path_string(),
String::NewFromUtf8(isolate,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToV8Value?

@jasnell

jasnell commented Aug 18, 2026

Copy link
Copy Markdown
Member

SGTM

@timfish

timfish commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Does this impact perf. much when the channels are not subscribed to?
What's the impact like when there is a subscriber that does nothing?

Depending on the impact with a subscriber it might be worth having a channel per operation so that we can be selective over which ops we want to impact?

@logaretm

Copy link
Copy Markdown
Contributor

I think having granularity via multiple channels is better because it allows APMs to choose what to subscribe to without adding overhead to NO-OP events.

Add built-in node:diagnostics_channel channels for file system
operations performed through node:fs and node:fs/promises. Each
operation gets its own TracingChannel family named fs.<operation>,
with channels tracing:fs.<operation>:start, :end, :asyncStart,
:asyncEnd, and :error. The event payload carries the API
(sync/callback/promise), path/dest/fd fields when applicable, plus
result/error following TracingChannel conventions.

Events are published from the internal shared file system layer rather
than the JS wrappers, so captured function references still emit events.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina force-pushed the fs-diagnostics-channel branch from 657db86 to 508ffc0 Compare August 28, 2026 18:17
@mcollina mcollina changed the title fs: add built-in fs.operation diagnostics channels fs: add per-operation fs diagnostics channels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants