Skip to content

util: add node.telemetry trace event category

Rodrigo Muino Tomonari requested to merge github/fork/jasnell/telemetry into master

At the Collaborator Summit, during the session discussing deprecations, the concept of adding a mechanism to optionally collect targeted telemetry data was discussed. This PR introduces one possible way of doing so while giving users complete opt-in control.

This adds a new node.telemetry trace event category and a new internal telemetry() function that we can selectively place at key locations within the code. When the node.telemetry trace category is enabled, the telemetry() function will emit a trace event, the key use of which shall just be to determine how many times a particular code path is used.

For instance,

const { telemetry } = require('util/internal/telemetry');

function someCoreFunction(arg) {
  telemetry('SOME_TRACE_ID', `Path used with arg: ${arg}`);
}

By running node.js with the --trace-event-categories=node.telemetry flag, the trace event log will include the telemetry entries that can then be optionally shared with the Node.js project.

The trace event is intentionally very simple.

/cc @addaleax @BridgeAR @Fishrock123

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading