Skip to main content
diagnostics_channel - Node documentation

Usage in Deno

import * as mod from "node:diagnostics_channel";

The node:diagnostics_channel module provides an API to create named channels to report arbitrary message data for diagnostics purposes.

It can be accessed using:

import diagnostics_channel from 'node:diagnostics_channel';

It is intended that a module writer wanting to report diagnostics messages will create one or many top-level channels to report messages through. Channels may also be acquired at runtime but it is not encouraged due to the additional overhead of doing so. Channels may be exported for convenience, but as long as the name is known it can be acquired anywhere.

If you intend for your module to produce diagnostics data for others to consume it is recommended that you include documentation of what named channels are used along with the shape of the message data. Channel names should generally include the module name to avoid collisions with data from other modules.

Classes

c
Channel

The class Channel represents an individual named channel within the datapipeline. It is used to track subscribers and to publish messages when thereare subscribers present. It exists as a separate object to avoid channellookups at publish time, enabling very fast publish speeds and allowingfor heavy use while incurring very minimal cost. Channels are created with channel, constructing a channel directlywith new Channel(name) is not supported.

c
TracingChannel

The class TracingChannel is a collection of TracingChannel Channels whichtogether express a single traceable action. It is used to formalize andsimplify the process of producing events for tracing application flow. tracingChannel is used to construct a TracingChannel. As with Channel it is recommended to create and reuse asingle TracingChannel at the top-level of the file rather than creating themdynamically.

Functions

f
channel

This is the primary entry-point for anyone wanting to publish to a namedchannel. It produces a channel object which is optimized to reduce overhead atpublish time as much as possible.

f
hasSubscribers

Check if there are active subscribers to the named channel. This is helpful ifthe message you want to send might be expensive to prepare.

f
subscribe

Register a message handler to subscribe to this channel. This message handlerwill be run synchronously whenever a message is published to the channel. Anyerrors thrown in the message handler will trigger an 'uncaughtException'.

f
tracingChannel

Creates a TracingChannel wrapper for the given TracingChannel Channels. If a name is given, the corresponding tracingchannels will be created in the form of tracing:${name}:${eventType} where eventType corresponds to the types of TracingChannel Channels.

f
unsubscribe

Remove a message handler previously registered to this channel with subscribe.

Interfaces

Type Aliases

T
ChannelListener
No documentation available