诊断通道


¥Diagnostics Channel

稳定性: 2 - 稳定的

¥Stability: 2 - Stable

源代码: lib/diagnostics_channel.js

node:diagnostics_channel 模块提供了一个 API 来创建命名通道来报告任意消息数据以用于诊断目的。

¥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';const diagnostics_channel = require('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.