trace_events.createTracing(options)


  • options <Object>

    • categories <string[]> 一组跟踪类别名称。在可能的情况下,数组中包含的值会被强制转换为字符串。如果无法强制转换该值,则会抛出错误。

      ¥categories <string[]> An array of trace category names. Values included in the array are coerced to a string when possible. An error will be thrown if the value cannot be coerced.

  • 返回:<Tracing>

    ¥Returns: <Tracing>.

为给定的 categories 集合创建并返回 Tracing 对象。

¥Creates and returns a Tracing object for the given set of categories.

import { createTracing } from 'node:trace_events';
const categories = ['node.perf', 'node.async_hooks'];
const tracing = createTracing({ categories });
tracing.enable();
// do stuff
tracing.disable();const { createTracing } = require('node:trace_events');
const categories = ['node.perf', 'node.async_hooks'];
const tracing = createTracing({ categories });
tracing.enable();
// do stuff
tracing.disable();