GIF89; GIF89; %PDF- %PDF-
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# Trace events
<!--introduced_in=v7.7.0-->
> Stability: 1 - Experimental
<!-- source_link=lib/trace_events.js -->
The `node:trace_events` module provides a mechanism to centralize tracing
information generated by V8, Node.js core, and userspace code.
Tracing can be enabled with the `--trace-event-categories` command-line flag
or by using the `node:trace_events` module. The `--trace-event-categories` flag
accepts a list of comma-separated category names.
The available categories are:
* `node`: An empty placeholder.
* `node.async_hooks`: Enables capture of detailed [`async_hooks`][] trace data.
The [`async_hooks`][] events have a unique `asyncId` and a special `triggerId`
`triggerAsyncId` property.
* `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
* `node.console`: Enables capture of `console.time()` and `console.count()`
output.
* `node.threadpoolwork.sync`: Enables capture of trace data for threadpool
synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
* `node.threadpoolwork.async`: Enables capture of trace data for threadpool
asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
* `node.dns.native`: Enables capture of trace data for DNS queries.
* `node.net.native`: Enables capture of trace data for network.
* `node.environment`: Enables capture of Node.js Environment milestones.
* `node.fs.sync`: Enables capture of trace data for file system sync methods.
* `node.fs_dir.sync`: Enables capture of trace data for file system sync
directory methods.
* `node.fs.async`: Enables capture of trace data for file system async methods.
* `node.fs_dir.async`: Enables capture of trace data for file system async
directory methods.
* `node.perf`: Enables capture of [Performance API][] measurements.
* `node.perf.usertiming`: Enables capture of only Performance API User Timing
measures and marks.
* `node.perf.timerify`: Enables capture of only Performance API timerify
measurements.
* `node.promises.rejections`: Enables capture of trace data tracking the number
of unhandled Promise rejections and handled-after-rejections.
* `node.vm.script`: Enables capture of trace data for the `node:vm` module's
`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
* `v8`: The [V8][] events are GC, compiling, and execution related.
* `node.http`: Enables capture of trace data for http request / response.
* `node.module_timer`: Enables capture of trace data for CJS Module loading.
By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
```bash
node --trace-event-categories v8,node,node.async_hooks server.js
```
Prior versions of Node.js required the use of the `--trace-events-enabled`
flag to enable trace events. This requirement has been removed. However, the
`--trace-events-enabled` flag _may_ still be used and will enable the
`node`, `node.async_hooks`, and `v8` trace event categories by default.
```bash
node --trace-events-enabled
# is equivalent to
node --trace-event-categories v8,node,node.async_hooks
```
Alternatively, trace events may be enabled using the `node:trace_events` module:
```mjs
import { createTracing } from 'node:trace_events';
const tracing = createTracing({ categories: ['node.perf'] });
tracing.enable(); // Enable trace event capture for the 'node.perf' category
// do work
tracing.disable(); // Disable trace event capture for the 'node.perf' category
```
```cjs
const { createTracing } = require('node:trace_events');
const tracing = createTracing({ categories: ['node.perf'] });
tracing.enable(); // Enable trace event capture for the 'node.perf' category
// do work
tracing.disable(); // Disable trace event capture for the 'node.perf' category
```
Running Node.js with tracing enabled will produce log files that can be opened
in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
tab of Chrome.
The logging file is by default called `node_trace.${rotation}.log`, where
`${rotation}` is an incrementing log-rotation id. The filepath pattern can
be specified with `--trace-event-file-pattern` that accepts a template
string that supports `${rotation}` and `${pid}`:
```bash
node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
```
To guarantee that the log file is properly generated after signal events like
`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
in your code, such as:
```js
process.on('SIGINT', function onSigint() {
console.info('Received SIGINT.');
process.exit(130); // Or applicable exit code depending on OS and signal
});
```
The tracing system uses the same time source
as the one used by `process.hrtime()`.
However the trace-event timestamps are expressed in microseconds,
unlike `process.hrtime()` which returns nanoseconds.
The features from this module are not available in [`Worker`][] threads.
## The `node:trace_events` module
<!-- YAML
added: v10.0.0
-->
### `Tracing` object
<!-- YAML
added: v10.0.0
-->
The `Tracing` object is used to enable or disable tracing for sets of
categories. Instances are created using the `trace_events.createTracing()`
method.
When created, the `Tracing` object is disabled. Calling the
`tracing.enable()` method adds the categories to the set of enabled trace event
categories. Calling `tracing.disable()` will remove the categories from the
set of enabled trace event categories.
#### `tracing.categories`
<!-- YAML
added: v10.0.0
-->
* Type: {string}
A comma-separated list of the trace event categories covered by this
`Tracing` object.
#### `tracing.disable()`
<!-- YAML
added: v10.0.0
-->
Disables this `Tracing` object.
Only trace event categories _not_ covered by other enabled `Tracing` objects
and _not_ specified by the `--trace-event-categories` flag will be disabled.
```mjs
import { createTracing, getEnabledCategories } from 'node:trace_events';
const t1 = createTracing({ categories: ['node', 'v8'] });
const t2 = createTracing({ categories: ['node.perf', 'node'] });
t1.enable();
t2.enable();
// Prints 'node,node.perf,v8'
console.log(getEnabledCategories());
t2.disable(); // Will only disable emission of the 'node.perf' category
// Prints 'node,v8'
console.log(getEnabledCategories());
```
```cjs
const { createTracing, getEnabledCategories } = require('node:trace_events');
const t1 = createTracing({ categories: ['node', 'v8'] });
const t2 = createTracing({ categories: ['node.perf', 'node'] });
t1.enable();
t2.enable();
// Prints 'node,node.perf,v8'
console.log(getEnabledCategories());
t2.disable(); // Will only disable emission of the 'node.perf' category
// Prints 'node,v8'
console.log(getEnabledCategories());
```
#### `tracing.enable()`
<!-- YAML
added: v10.0.0
-->
Enables this `Tracing` object for the set of categories covered by the
`Tracing` object.
#### `tracing.enabled`
<!-- YAML
added: v10.0.0
-->
* Type: {boolean} `true` only if the `Tracing` object has been enabled.
### `trace_events.createTracing(options)`
<!-- YAML
added: v10.0.0
-->
* `options` {Object}
* `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.
* Returns: {Tracing}.
Creates and returns a `Tracing` object for the given set of `categories`.
```mjs
import { createTracing } from 'node:trace_events';
const categories = ['node.perf', 'node.async_hooks'];
const tracing = createTracing({ categories });
tracing.enable();
// do stuff
tracing.disable();
```
```cjs
const { createTracing } = require('node:trace_events');
const categories = ['node.perf', 'node.async_hooks'];
const tracing = createTracing({ categories });
tracing.enable();
// do stuff
tracing.disable();
```
### `trace_events.getEnabledCategories()`
<!-- YAML
added: v10.0.0
-->
* Returns: {string}
Returns a comma-separated list of all currently-enabled trace event
categories. The current set of enabled trace event categories is determined
by the _union_ of all currently-enabled `Tracing` objects and any categories
enabled using the `--trace-event-categories` flag.
Given the file `test.js` below, the command
`node --trace-event-categories node.perf test.js` will print
`'node.async_hooks,node.perf'` to the console.
```mjs
import { createTracing, getEnabledCategories } from 'node:trace_events';
const t1 = createTracing({ categories: ['node.async_hooks'] });
const t2 = createTracing({ categories: ['node.perf'] });
const t3 = createTracing({ categories: ['v8'] });
t1.enable();
t2.enable();
console.log(getEnabledCategories());
```
```cjs
const { createTracing, getEnabledCategories } = require('node:trace_events');
const t1 = createTracing({ categories: ['node.async_hooks'] });
const t2 = createTracing({ categories: ['node.perf'] });
const t3 = createTracing({ categories: ['v8'] });
t1.enable();
t2.enable();
console.log(getEnabledCategories());
```
## Examples
### Collect trace events data by inspector
```mjs
import { Session } from 'node:inspector';
const session = new Session();
session.connect();
function post(message, data) {
return new Promise((resolve, reject) => {
session.post(message, data, (err, result) => {
if (err)
reject(new Error(JSON.stringify(err)));
else
resolve(result);
});
});
}
async function collect() {
const data = [];
session.on('NodeTracing.dataCollected', (chunk) => data.push(chunk));
session.on('NodeTracing.tracingComplete', () => {
// done
});
const traceConfig = { includedCategories: ['v8'] };
await post('NodeTracing.start', { traceConfig });
// do something
setTimeout(() => {
post('NodeTracing.stop').then(() => {
session.disconnect();
console.log(data);
});
}, 1000);
}
collect();
```
```cjs
'use strict';
const { Session } = require('node:inspector');
const session = new Session();
session.connect();
function post(message, data) {
return new Promise((resolve, reject) => {
session.post(message, data, (err, result) => {
if (err)
reject(new Error(JSON.stringify(err)));
else
resolve(result);
});
});
}
async function collect() {
const data = [];
session.on('NodeTracing.dataCollected', (chunk) => data.push(chunk));
session.on('NodeTracing.tracingComplete', () => {
// done
});
const traceConfig = { includedCategories: ['v8'] };
await post('NodeTracing.start', { traceConfig });
// do something
setTimeout(() => {
post('NodeTracing.stop').then(() => {
session.disconnect();
console.log(data);
});
}, 1000);
}
collect();
```
[Performance API]: perf_hooks.md
[V8]: v8.md
[`Worker`]: worker_threads.md#class-worker
[`async_hooks`]: async_hooks.md
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| assets | Folder | 0755 |
|
|
| addons.html | File | 107.46 KB | 0644 |
|
| addons.json.gz | File | 11.01 KB | 0644 |
|
| addons.md | File | 39.89 KB | 0644 |
|
| all.html | File | 8.67 MB | 0644 |
|
| all.json.gz | File | 1.01 MB | 0644 |
|
| assert.html | File | 215.02 KB | 0644 |
|
| assert.json.gz | File | 15.05 KB | 0644 |
|
| assert.md | File | 72.71 KB | 0644 |
|
| async_context.html | File | 85.71 KB | 0644 |
|
| async_context.json.gz | File | 7.18 KB | 0644 |
|
| async_context.md | File | 25.17 KB | 0644 |
|
| async_hooks.html | File | 88.88 KB | 0644 |
|
| async_hooks.json.gz | File | 9.82 KB | 0644 |
|
| async_hooks.md | File | 30.52 KB | 0644 |
|
| buffer.html | File | 484.41 KB | 0644 |
|
| buffer.json.gz | File | 29.12 KB | 0644 |
|
| buffer.md | File | 149.42 KB | 0644 |
|
| child_process.html | File | 214.18 KB | 0644 |
|
| child_process.json.gz | File | 21.81 KB | 0644 |
|
| child_process.md | File | 83.3 KB | 0644 |
|
| cli.html | File | 258.67 KB | 0644 |
|
| cli.json.gz | File | 39.13 KB | 0644 |
|
| cli.md | File | 113.19 KB | 0644 |
|
| cluster.html | File | 92.16 KB | 0644 |
|
| cluster.json.gz | File | 9.46 KB | 0644 |
|
| cluster.md | File | 28.89 KB | 0644 |
|
| console.html | File | 63.73 KB | 0644 |
|
| console.json.gz | File | 6.28 KB | 0644 |
|
| console.md | File | 17.38 KB | 0644 |
|
| corepack.html | File | 15.56 KB | 0644 |
|
| corepack.json | File | 866 B | 0644 |
|
| corepack.md | File | 401 B | 0644 |
|
| crypto.html | File | 526.52 KB | 0644 |
|
| crypto.json.gz | File | 46.5 KB | 0644 |
|
| crypto.md | File | 193.72 KB | 0644 |
|
| debugger.html | File | 30.54 KB | 0644 |
|
| debugger.json.gz | File | 3.42 KB | 0644 |
|
| debugger.md | File | 7.88 KB | 0644 |
|
| deprecations.html | File | 237.81 KB | 0644 |
|
| deprecations.json.gz | File | 28.63 KB | 0644 |
|
| deprecations.md | File | 117.72 KB | 0644 |
|
| dgram.html | File | 93.62 KB | 0644 |
|
| dgram.json.gz | File | 10.63 KB | 0644 |
|
| dgram.md | File | 32.28 KB | 0644 |
|
| diagnostics_channel.html | File | 130.69 KB | 0644 |
|
| diagnostics_channel.json.gz | File | 10.38 KB | 0644 |
|
| diagnostics_channel.md | File | 39.31 KB | 0644 |
|
| dns.html | File | 150.29 KB | 0644 |
|
| dns.json.gz | File | 16.91 KB | 0644 |
|
| dns.md | File | 59.01 KB | 0644 |
|
| documentation.html | File | 27.74 KB | 0644 |
|
| documentation.json.gz | File | 2.57 KB | 0644 |
|
| documentation.md | File | 5.68 KB | 0644 |
|
| domain.html | File | 49.94 KB | 0644 |
|
| domain.json.gz | File | 6.21 KB | 0644 |
|
| domain.md | File | 15.21 KB | 0644 |
|
| embedding.html | File | 27.42 KB | 0644 |
|
| embedding.json.gz | File | 3.03 KB | 0644 |
|
| embedding.md | File | 6.74 KB | 0644 |
|
| environment_variables.html | File | 24.29 KB | 0644 |
|
| environment_variables.json.gz | File | 2.58 KB | 0644 |
|
| environment_variables.md | File | 5.08 KB | 0644 |
|
| errors.html | File | 337.36 KB | 0644 |
|
| errors.json.gz | File | 47.68 KB | 0644 |
|
| errors.md | File | 112.09 KB | 0644 |
|
| esm.html | File | 93.22 KB | 0644 |
|
| esm.json.gz | File | 16 KB | 0644 |
|
| esm.md | File | 44.27 KB | 0644 |
|
| events.html | File | 236.33 KB | 0644 |
|
| events.json.gz | File | 17.91 KB | 0644 |
|
| events.md | File | 68.71 KB | 0644 |
|
| fs.html | File | 666.11 KB | 0644 |
|
| fs.json.gz | File | 71.32 KB | 0644 |
|
| fs.md | File | 263.58 KB | 0644 |
|
| globals.html | File | 98.26 KB | 0644 |
|
| globals.json.gz | File | 12.43 KB | 0644 |
|
| globals.md | File | 29.48 KB | 0644 |
|
| http.html | File | 330.81 KB | 0644 |
|
| http.json.gz | File | 40 KB | 0644 |
|
| http.md | File | 126.6 KB | 0644 |
|
| http2.html | File | 389.2 KB | 0644 |
|
| http2.json.gz | File | 42.34 KB | 0644 |
|
| http2.md | File | 152.2 KB | 0644 |
|
| https.html | File | 72.6 KB | 0644 |
|
| https.json.gz | File | 6.21 KB | 0644 |
|
| https.md | File | 21.04 KB | 0644 |
|
| index.html | File | 13.9 KB | 0644 |
|
| index.json | File | 54 B | 0644 |
|
| index.md | File | 2.06 KB | 0644 |
|
| inspector.html | File | 65.18 KB | 0644 |
|
| inspector.json.gz | File | 5.74 KB | 0644 |
|
| inspector.md | File | 17.75 KB | 0644 |
|
| intl.html | File | 34.48 KB | 0644 |
|
| intl.json.gz | File | 4.12 KB | 0644 |
|
| intl.md | File | 11.49 KB | 0644 |
|
| module.html | File | 171.06 KB | 0644 |
|
| module.json.gz | File | 21.59 KB | 0644 |
|
| module.md | File | 69.85 KB | 0644 |
|
| modules.html | File | 96.67 KB | 0644 |
|
| modules.json.gz | File | 14.83 KB | 0644 |
|
| modules.md | File | 40.53 KB | 0644 |
|
| n-api.html | File | 432.96 KB | 0644 |
|
| n-api.json.gz | File | 55.7 KB | 0644 |
|
| n-api.md | File | 235.86 KB | 0644 |
|
| net.html | File | 167.45 KB | 0644 |
|
| net.json.gz | File | 20.51 KB | 0644 |
|
| net.md | File | 60.3 KB | 0644 |
|
| os.html | File | 74.59 KB | 0644 |
|
| os.json.gz | File | 9.18 KB | 0644 |
|
| os.md | File | 36.29 KB | 0644 |
|
| packages.html | File | 89.9 KB | 0644 |
|
| packages.json.gz | File | 13.05 KB | 0644 |
|
| packages.md | File | 38.8 KB | 0644 |
|
| path.html | File | 57.7 KB | 0644 |
|
| path.json.gz | File | 5.43 KB | 0644 |
|
| path.md | File | 16.48 KB | 0644 |
|
| perf_hooks.html | File | 187.34 KB | 0644 |
|
| perf_hooks.json.gz | File | 13.83 KB | 0644 |
|
| perf_hooks.md | File | 59.15 KB | 0644 |
|
| permissions.html | File | 29.01 KB | 0644 |
|
| permissions.json.gz | File | 3.64 KB | 0644 |
|
| permissions.md | File | 8.35 KB | 0644 |
|
| process.html | File | 343.73 KB | 0644 |
|
| process.json.gz | File | 37.12 KB | 0644 |
|
| process.md | File | 128.36 KB | 0644 |
|
| punycode.html | File | 27.65 KB | 0644 |
|
| punycode.json.gz | File | 2 KB | 0644 |
|
| punycode.md | File | 4.19 KB | 0644 |
|
| querystring.html | File | 29.92 KB | 0644 |
|
| querystring.json.gz | File | 2.65 KB | 0644 |
|
| querystring.md | File | 5.55 KB | 0644 |
|
| readline.html | File | 115.99 KB | 0644 |
|
| readline.json.gz | File | 11.81 KB | 0644 |
|
| readline.md | File | 41.32 KB | 0644 |
|
| repl.html | File | 96.41 KB | 0644 |
|
| repl.json.gz | File | 11.56 KB | 0644 |
|
| repl.md | File | 31.55 KB | 0644 |
|
| report.html | File | 101.16 KB | 0644 |
|
| report.json.gz | File | 7.44 KB | 0644 |
|
| report.md | File | 23.41 KB | 0644 |
|
| single-executable-applications.html | File | 52.13 KB | 0644 |
|
| single-executable-applications.json.gz | File | 6.77 KB | 0644 |
|
| single-executable-applications.md | File | 18.27 KB | 0644 |
|
| sqlite.html | File | 92.73 KB | 0644 |
|
| sqlite.json.gz | File | 11 KB | 0644 |
|
| sqlite.md | File | 34.86 KB | 0644 |
|
| stream.html | File | 412.01 KB | 0644 |
|
| stream.json.gz | File | 53.26 KB | 0644 |
|
| stream.md | File | 152.09 KB | 0644 |
|
| string_decoder.html | File | 28.31 KB | 0644 |
|
| string_decoder.json.gz | File | 1.59 KB | 0644 |
|
| string_decoder.md | File | 3.57 KB | 0644 |
|
| synopsis.html | File | 20.35 KB | 0644 |
|
| synopsis.json | File | 2.96 KB | 0644 |
|
| synopsis.md | File | 2.11 KB | 0644 |
|
| test.html | File | 343.78 KB | 0644 |
|
| test.json.gz | File | 31.84 KB | 0644 |
|
| test.md | File | 122.47 KB | 0644 |
|
| timers.html | File | 62.4 KB | 0644 |
|
| timers.json.gz | File | 5.33 KB | 0644 |
|
| timers.md | File | 16.76 KB | 0644 |
|
| tls.html | File | 203.47 KB | 0644 |
|
| tls.json.gz | File | 35.24 KB | 0644 |
|
| tls.md | File | 98.58 KB | 0644 |
|
| tracing.html | File | 43.55 KB | 0644 |
|
| tracing.json.gz | File | 3.58 KB | 0644 |
|
| tracing.md | File | 10.58 KB | 0644 |
|
| tty.html | File | 40.73 KB | 0644 |
|
| tty.json.gz | File | 3.88 KB | 0644 |
|
| tty.md | File | 9.56 KB | 0644 |
|
| typescript.html | File | 29.27 KB | 0644 |
|
| typescript.json.gz | File | 3.38 KB | 0644 |
|
| typescript.md | File | 7.69 KB | 0644 |
|
| url.html | File | 161.29 KB | 0644 |
|
| url.json.gz | File | 16.67 KB | 0644 |
|
| url.md | File | 57.4 KB | 0644 |
|
| util.html | File | 351.85 KB | 0644 |
|
| util.json.gz | File | 30.22 KB | 0644 |
|
| util.md | File | 114.07 KB | 0644 |
|
| v8.html | File | 134.81 KB | 0644 |
|
| v8.json.gz | File | 14.51 KB | 0644 |
|
| v8.md | File | 43.79 KB | 0644 |
|
| vm.html | File | 188 KB | 0644 |
|
| vm.json.gz | File | 22.9 KB | 0644 |
|
| vm.md | File | 80.88 KB | 0644 |
|
| wasi.html | File | 32.28 KB | 0644 |
|
| wasi.json.gz | File | 3.49 KB | 0644 |
|
| wasi.md | File | 8.25 KB | 0644 |
|
| webcrypto.html | File | 161.61 KB | 0644 |
|
| webcrypto.json.gz | File | 10.2 KB | 0644 |
|
| webcrypto.md | File | 47.22 KB | 0644 |
|
| webstreams.html | File | 165.16 KB | 0644 |
|
| webstreams.json.gz | File | 10.95 KB | 0644 |
|
| webstreams.md | File | 41.21 KB | 0644 |
|
| worker_threads.html | File | 169.32 KB | 0644 |
|
| worker_threads.json.gz | File | 17.33 KB | 0644 |
|
| worker_threads.md | File | 59.46 KB | 0644 |
|
| zlib.html | File | 156.29 KB | 0644 |
|
| zlib.json.gz | File | 12.86 KB | 0644 |
|
| zlib.md | File | 49 KB | 0644 |
|