node:diagnostics_channel API Reference

Named diagnostic channels and tracing helpers

import diagnostics from "node:diagnostics_channel";

const channel = diagnostics.channel("app.request");
const receive = (message, name) => console.log(name, message);

channel.subscribe(receive);
channel.publish({ path: "/" });
channel.unsubscribe(receive);

Repeated calls to channel(name) return the same Channel. The module also exports hasSubscribers, subscribe, unsubscribe, tracingChannel, Channel, and the Elide extensions boundedChannel and BoundedChannel.

Channels support bindStore, unbindStore, and runStores, but store behavior inherits the partial async-context propagation described in node:async_hooks.