Node.js channels carry globally available events and are split into separate objects to maintain performance. Publishing events when nothing is listening for them is designed to use as little overhead as possible. Consuming channel data happens via a subscription that runs a function whenever a message is published to that channel.
“Diagnostics_channel is a new experimental module that provides an API to create named channels to report arbitrary message data for diagnostics purposes,” Michael Zasso of the Node.js Technical Steering Committee said in a blog post .
“With diagnostics_channel, Node.js core and module authors can publish contextual data about what they are doing at a given time. This could be the hostname and query string of a mysql query, for example. Just create a named channel with dc.channel(name) and call channel.publish(data) to send the data to any listeners to that channel.”
Such data can be used for things like augmenting tracing data, tracking network and filesystem activity, logging queries, and many other diagnostic functions familiar to programmers during debugging or performance analysis, the developers noted. It also provides a useful source for other diagnostic tools, instrumenting Node.js code during runtime.