Node Setup
Node.js auto-instrumentation for backend spans, traces, and logs.
OpenTelemetry has automatic instrumentation available for almost every Node.js stack. Include the autoinstrumentation package by installing the following:
This module includes auto instrumentation for all supported instrumentations and all available data exporters.
This includes many popular frameworks such as Fastify
, Express
, redis
, graphql
, aws-lambda
, and dozens others.
It provides a completely automatic, out-of-the-box experience. Please see the
Supported Instrumentations
section for more information.
The module is enabled and highly configurable using environment variables.
You can enable Node auto-instrumentation via an environment variable before running Node.
Many aspects of the auto instrumentation’s behavior can be configured for your needs, such as resource detectors, exporter choice, exporter configuration, trace context propagation headers, and much more. Instrumentation configuration is not yet supported through environment variables. Users that require instrumentation configuration must initialize OpenTelemetry programmatically.
Out of the box, all the resource detectors are enabled. If you get some sort of an error, such as “Process is not running in a K8S server” or something else like that, you can scope the resource detectors to a more limited set. You can find the full list of resource detectors here.
With these environment variables, you will finally be able to start your server with autoinstrumentation:
Was this page helpful?