Node.js
The Dash0 distribution of the OpenTelemetry Node.js SDK, packaged so the OpenTelemetry injector can load it into Node.js processes on a host.
Compatibility
| Requirement | Supported |
|---|---|
| Node.js | 16.0.0 or later; 26 and later are not tested yet |
| Node.js, for configuration files | 18.19.0 or later, excluding 20.0.0 to 20.5.1 |
| Architectures | Any |
| Distribution requirements | Supported Node.js versions |
Setup with the injector
This is the recommended setup: the injector instruments every Node.js process on the host when it starts, without changes to how you start your applications. There are two ways to install it.
With dash0-opentelemetry, install the metapackage.
It brings the injector, the keyring and, as recommended packages, the language packages for all runtimes, Node.js included.
On Debian or Ubuntu:
sudo apt-get install dash0-opentelemetryOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-opentelemetryWith only the packages you need, install this package and the injector by name.
On Debian or Ubuntu:
sudo apt-get install dash0-injector dash0-nodejs-autoinstrumentationOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-injector dash0-nodejs-autoinstrumentationIn both cases, the package's drop-in at /etc/opentelemetry/injector/conf.d/nodejs.conf tells the injector where the entry point is.
The injector then adds --require /usr/lib/opentelemetry/nodejs/register.js to NODE_OPTIONS for every Node.js process that starts, and applies default_env.conf to it.
Node.js processes that are already running are instrumented only after they restart.
Then set the endpoint and the auth token in default_env.conf, as described under Configuration.
Setup without the injector
Install only this package.
On Debian or Ubuntu:
sudo apt-get install dash0-nodejs-autoinstrumentationOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-nodejs-autoinstrumentationOn its own, the package instruments nothing. It only suggests the injector, and apt and dnf do not install suggested packages. Load the instrumentation yourself when you start the process:
node --require /usr/lib/opentelemetry/nodejs/register.js app.jsWithout the injector, default_env.conf is not applied: set the endpoint and the auth token in the environment of the process instead, as described under Configuration.
Configuration
All setups need the same settings, as environment variables:
| Variable | Sets |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | The Dash0 OTLP endpoint to send telemetry to |
OTEL_EXPORTER_OTLP_HEADERS | The auth token and the dataset |
OTEL_SERVICE_NAME | Optional: the service name, which otherwise comes from the application's package.json; see How the service name is chosen |
With the injector, set them in /etc/opentelemetry/injector/default_env.conf, which the injector applies to every process it instruments:
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=defaultWithout the injector, set them in the environment of the process, for example in the [Service] section of its systemd unit:
Environment=OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
Environment=OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=defaultIn both setups, the declarative configuration file this package ships reads these variables, so they are the only settings most hosts need.
Note that white spaces in OTEL_EXPORTER_OTLP_HEADERS, like in Bearer <token>, must be written %20.
Set the endpoint without a trailing slash, since the signal paths such as /v1/traces are appended to it.
A variable in default_env.conf replaces the value a process sets itself, so set OTEL_SERVICE_NAME and other per-application settings in the environment of the application, not in default_env.conf.
DASH0_OTEL_COLLECTOR_BASE_URL is the endpoint when OTEL_EXPORTER_OTLP_ENDPOINT is unset or empty, as in the other Dash0 distributions.
DASH0_DISABLE=true leaves processes uninstrumented without uninstalling the package.
With the injector, the DASH0_ variables reach the process only through dash0-injector, because upstream's opentelemetry-injector forwards only OTEL_-prefixed names.
Declarative configuration
Like the upstream Node.js package, this package ships /etc/opentelemetry/nodejs/otel-config.yaml, an OpenTelemetry declarative configuration file.
Unlike the upstream package, the distribution reads it whenever OTEL_CONFIG_FILE is unset or empty, so it configures every instrumented Node.js process by default.
Configuration on the overview describes how to use a file of your own, the propagators every shipped file declares, and what happens to an edited file on upgrade, on removal and when replacing the upstream package.
The file uses OpenTelemetry declarative configuration , the standard YAML configuration format of the OpenTelemetry project, whose schema is defined in open-telemetry/opentelemetry-configuration .
${VARIABLE:-default} takes the value of an environment variable, with a default for when it is unset.
This excerpt of the shipped file shows the propagators, the resource detectors and the export of traces; metrics and logs are exported in the same way:
file_format: "1.0"
propagator:
composite:
- tracecontext: {}
- baggage: {}
- xray: {}
resource:
detection/development:
detectors:
- host: {}
- process: {}
- service: {}
- dash0_distribution: {}
- dash0_service_name: {}
- dash0_kubernetes: {}
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES:-}
tracer_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces
headers_list: ${OTEL_EXPORTER_OTLP_HEADERS:-}
compression: ${OTEL_EXPORTER_OTLP_COMPRESSION:-none}Supported environment variables
With a configuration file in effect, the file is the whole SDK configuration, and the SDK reads no OTEL_ variable of its own.
The shipped file interpolates these, so default_env.conf stays the one place to set them:
| Variable | Default in the file |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4318 |
OTEL_EXPORTER_OTLP_HEADERS | empty |
OTEL_EXPORTER_OTLP_COMPRESSION | none |
OTEL_RESOURCE_ATTRIBUTES | empty |
OTEL_METRIC_EXPORT_INTERVAL | 60000 ms |
OTEL_METRIC_EXPORT_TIMEOUT | 30000 ms |
A configuration file of your own has to carry the same interpolations to keep them.
OTEL_SERVICE_NAME keeps working through the service and dash0_service_name detectors the file lists, and DASH0_AUTOMATIC_SERVICE_NAME through dash0_service_name.
DASH0_OTEL_COLLECTOR_BASE_URL keeps working as the default for OTEL_EXPORTER_OTLP_ENDPOINT.
DASH0_DISABLE, DASH0_DEBUG, DASH0_BOOTSTRAP_SPAN, DASH0_ENABLE_FS_INSTRUMENTATION, DASH0_FLUSH_ON_SIGTERM_SIGINT, DASH0_FLUSH_ON_EMPTY_EVENT_LOOP and OTEL_NODE_ENABLED_INSTRUMENTATIONS apply in either mode.
Unsupported environment variables
- Every other
OTEL_variable, unless the file interpolates it. OTEL_PROPAGATORS. Edit the file'spropagatorlist instead.OTEL_NODE_RESOURCE_DETECTORS. Edit the file'sdetectorslist instead, which can only name the detectors listed under Resource detectors.OTEL_SDK_DISABLED. UseDASH0_DISABLEinstead.DASH0_DEBUG_PRINT_SPANS. Add a span processor with aconsoleexporter to the file instead.
Resource detectors
The shipped file lists the upstream host, process and service resource detectors, and the distribution's dash0_distribution, dash0_service_name and dash0_kubernetes.
Resource detection describes what each one adds.
Node.js cannot name the container detector in a configuration file yet, so container.id is reported only without one.
Resource attributes
Every instrumented process reports the package it came from:
| Attribute | Value |
|---|---|
dash0.package.name | dash0-nodejs-autoinstrumentation |
dash0.package.version | The installed package version, packaging revision included |
The dash0.package.* attributes are added to OTEL_RESOURCE_ATTRIBUTES before the SDK starts, and a value set there in default_env.conf or the process environment overrides them.
A configuration file of your own keeps them only if it reads OTEL_RESOURCE_ATTRIBUTES through attributes_list, as the shipped file does.
The distribution adds the other resource attributes, such as service.name and telemetry.distro.*.
Resource detection in the distribution docs describes them, and how the service name is chosen, with and without a configuration file.
Conditional instrumentation
The application keeps running in every case below, without telemetry.
The distribution writes one line to stderr, starting with [Dash0 OpenTelemetry Distribution] and ending with "OpenTelemetry data will not be sent to Dash0.", unless noted otherwise.
DASH0_DISABLE=true.- Node.js older than 16.0.0.
- Node.js older than 18.19.0, or 20.0.0 to 20.5.1, without an endpoint: these versions cannot read a configuration file, so without
OTEL_EXPORTER_OTLP_ENDPOINTorDASH0_OTEL_COLLECTOR_BASE_URLthe distribution does not start. With an endpoint, they skip the shipped file silently, and a file set withOTEL_CONFIG_FILEwith a warning. - Another OpenTelemetry SDK already loaded: when the process has already loaded
@opentelemetry/sdk-nodebefore the distribution, for example through another--require, the distribution stands down to avoid double instrumentation. - A configuration file that is not valid, or that names a detector Node.js does not know: the SDK writes "Could not load / create OpenTelemetry configuration, SDK will not be setup" to stderr.
OTEL_SDK_DISABLED=truewithout a configuration file. With a configuration file it has no effect; useDASH0_DISABLE.- The package cannot load the distribution:
register.jswrites a line starting with[dash0-nodejs-autoinstrumentation] WARN: cannot auto-instrumentto stderr.
With the injector, the injector itself skips processes it cannot instrument, and logs why on stderr with OTEL_INJECTOR_LOG_LEVEL=info.
See the Injector page.
Installed files
| Path | Purpose |
|---|---|
/usr/lib/opentelemetry/nodejs/register.js | The entry point, loaded with node --require |
/usr/lib/opentelemetry/nodejs/node_modules/ | The bundled distribution and its dependencies |
/usr/lib/opentelemetry/nodejs/package.json, /usr/lib/opentelemetry/nodejs/package-lock.json | The versions of the bundled dependencies |
/etc/opentelemetry/injector/conf.d/nodejs.conf | Tells the injector where the entry point is |
/etc/opentelemetry/nodejs/otel-config.yaml | The declarative configuration file, read whenever OTEL_CONFIG_FILE is unset or empty; a conffile, so an edited copy is kept on upgrade |
/usr/share/man/man8/opentelemetry-nodejs.8.gz | The manual page, for man opentelemetry-nodejs |
/usr/share/doc/dash0-nodejs-autoinstrumentation/README.md | The installed copy of this page |
/usr/share/doc/dash0-nodejs-autoinstrumentation/copyright | The license statement and the notice, DEB only |
/usr/share/licenses/dash0-nodejs-autoinstrumentation/LICENSE | The license, RPM only |
/usr/share/licenses/dash0-nodejs-autoinstrumentation/NOTICE | The notice, RPM only |
Local overrides belong in a conf.d file that sorts after the package-managed one.
The injector reads conf.d in byte order and the last setting wins, so a digit prefix such as 99- sorts before nodejs.conf; use a name such as zz-local-nodejs.conf.
Edits to nodejs.conf itself are replaced on upgrade.
Dependencies
| Package | Relation | Why |
|---|---|---|
dash0-keyring | Depends | Every Dash0 package depends on it, so the signing certificate is owned by a package that upgrades it |
dash0-injector | Suggests | Instruments processes with this package; apt and dnf do not install suggested packages, so install the injector by name, as described under Setup with the injector |
opentelemetry-nodejs-autoinstrumentation | Conflicts, and Replaces on DEB or Obsoletes on RPM | Takes the place of the upstream package; see Reverting to the upstream package |
Versioning
The package version is the version of the bundled @dash0/opentelemetry distribution, followed by a packaging revision: 6.0.0-1 is the first package built from distribution 6.0.0, 6.0.0-2 a later package built from the same distribution.
On RPM distributions the revision is the Release field, so rpm -q shows 6.0.0-1 as version 6.0.0, release 1.
Reverting to the upstream package
On Debian and Ubuntu:
sudo apt-get install opentelemetry-nodejs-autoinstrumentationOn RPM distributions, this package declares Obsoletes on the upstream name, so a plain dnf install of it redirects back here.
Ask for the swap explicitly:
sudo dnf swap --setopt=obsoletes=0 dash0-nodejs-autoinstrumentation opentelemetry-nodejs-autoinstrumentationThe upstream package reads a configuration file only when OTEL_CONFIG_FILE names it, and its SDK does not know the dash0_* detectors and refuses to start from a file that lists them.
If you edited the shipped file and point OTEL_CONFIG_FILE at it after switching, remove the dash0_* detectors from it first, or the processes run without telemetry.
Source
Last updated: