boundedChannel.hasSubscribers


  • 返回:<boolean> true 如果任意一个单独的通道有订阅者,false 如果没有。

检查 startend 通道是否有订阅者。

🌐 Check if any of the start or end channels have subscribers.

import { boundedChannel } from 'node:diagnostics_channel';

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

if (wc.hasSubscribers) {
  // There are subscribers, perform traced operation
}const { boundedChannel } = require('node:diagnostics_channel');

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

if (wc.hasSubscribers) {
  // There are subscribers, perform traced operation
}