method

diagnostics_channel.BoundedChannel.subscribe

handlers: PartialOptions<BoundedChannelSubscribers<ContextType>>
): void;

Subscribe to the bounded channel events. This is equivalent to calling [channel.subscribe(onMessage)][] on each channel individually.

import { boundedChannel } from 'node:diagnostics_channel';

const wc = boundedChannel('my-operation');

wc.subscribe({
  start(message) {
    // Handle start
  },
  end(message) {
    // Handle end
  },
});
@param handlers

Set of channel subscribers

Referenced types

interface BoundedChannelSubscribers<ContextType extends object>

  • end: (message: ContextType) => void
  • start: (message: ContextType) => void