0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-module-cjs-helpers.js
James M Snell 5c27e44488 trace_events: adds a new trace_events api
Removes the requirement to use `--trace-events-enabled` to enable
trace events. Tracing is enabled automatically if there are any
enabled categories.

Adds a new `trace_events` module with an API for enabling/disabling
trace events at runtime without a command line flag.

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

Multiple `Tracing` objects may exist and be enabled at any point
in time. The enabled trace event categories is the union of all
enabled `Tracing` objects and the `--trace-event-categories`
flag.

PR-URL: https://github.com/nodejs/node/pull/19803
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2018-04-17 08:30:20 -07:00

12 lines
339 B
JavaScript

'use strict';
// Flags: --expose-internals
require('../common');
const assert = require('assert');
const { builtinLibs } = require('internal/modules/cjs/helpers');
const hasInspector = process.config.variables.v8_enable_inspector === 1;
const expectedLibs = hasInspector ? 33 : 32;
assert.strictEqual(builtinLibs.length, expectedLibs);