Zero-Code Instrumentation Configuration
Learn how to configure Zero-Code Instrumentation for Node.js
Zero-code instrumentation for JavaScript provides a way to instrument any Node.js application and capture telemetry data from many popular libraries and frameworks without any code changes.
Run the following commands to install the appropriate packages.
npm install --save @opentelemetry/api
npm install --save @opentelemetry/auto-instrumentations-node
The @opentelemetry/api
and @opentelemetry/auto-instrumentations-node
packages install the API, SDK, and the instrumentation tools.
The module is highly configurable.
One option is to configure the module by way of using env
to set environment
variables from the CLI:
env OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=your-endpoint \
node --require @opentelemetry/auto-instrumentations-node/register app.js
Alternatively, you can use export
to set environment variables:
export OTEL_TRACES_EXPORTER="otlp"
export OTEL_EXPORTER_OTLP_ENDPOINT="your-endpoint"
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os"
export OTEL_SERVICE_NAME="your-service-name"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
node app.js
By default, all SDK resource detectors are
used. You can use the environment variable OTEL_NODE_RESOURCE_DETECTORS
to
enable only certain detectors, or to completely disable them.
To see the full range of configuration options, see Module Configuration.
A number of popular Node.js libraries are auto-instrumented. For the full list, see supported instrumentation.
You can set the log level by setting the OTEL_LOG_LEVEL
environment variable
to one of the following:
none
error
warn
info
debug
verbose
all
The default level is info
.
OTEL_LOG_LEVEL
to
info
.console
, no matter the environment or debug level.Learn how to configure Zero-Code Instrumentation for Node.js
Cette page est-elle utile?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!