Node.js

The Dash0 distribution of the OpenTelemetry Node.js SDK, as a DEB and RPM package.

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

RequirementSupported
Node.js16.0.0 or later; 26 and later are not tested yet
Node.js, for configuration files18.19.0 or later, excluding 20.0.0 to 20.5.1
ArchitecturesAny
Distribution requirementsSupported 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-opentelemetry

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-opentelemetry

With 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-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-injector dash0-nodejs-autoinstrumentation

In 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-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-nodejs-autoinstrumentation

On 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.js

Without 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:

VariableSets
OTEL_EXPORTER_OTLP_ENDPOINTThe Dash0 OTLP endpoint to send telemetry to
OTEL_EXPORTER_OTLP_HEADERSThe auth token and the dataset
OTEL_SERVICE_NAMEOptional: 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=default

Without 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=default

In 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:

VariableDefault in the file
OTEL_EXPORTER_OTLP_ENDPOINThttp://localhost:4318
OTEL_EXPORTER_OTLP_HEADERSempty
OTEL_EXPORTER_OTLP_COMPRESSIONnone
OTEL_RESOURCE_ATTRIBUTESempty
OTEL_METRIC_EXPORT_INTERVAL60000 ms
OTEL_METRIC_EXPORT_TIMEOUT30000 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's propagator list instead.
  • OTEL_NODE_RESOURCE_DETECTORS. Edit the file's detectors list instead, which can only name the detectors listed under Resource detectors.
  • OTEL_SDK_DISABLED. Use DASH0_DISABLE instead.
  • DASH0_DEBUG_PRINT_SPANS. Add a span processor with a console exporter 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:

AttributeValue
dash0.package.namedash0-nodejs-autoinstrumentation
dash0.package.versionThe 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_ENDPOINT or DASH0_OTEL_COLLECTOR_BASE_URL the distribution does not start. With an endpoint, they skip the shipped file silently, and a file set with OTEL_CONFIG_FILE with a warning.
  • Another OpenTelemetry SDK already loaded: when the process has already loaded @opentelemetry/sdk-node before 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=true without a configuration file. With a configuration file it has no effect; use DASH0_DISABLE.
  • The package cannot load the distribution: register.js writes a line starting with [dash0-nodejs-autoinstrumentation] WARN: cannot auto-instrument to 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

PathPurpose
/usr/lib/opentelemetry/nodejs/register.jsThe 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.jsonThe versions of the bundled dependencies
/etc/opentelemetry/injector/conf.d/nodejs.confTells the injector where the entry point is
/etc/opentelemetry/nodejs/otel-config.yamlThe 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.gzThe manual page, for man opentelemetry-nodejs
/usr/share/doc/dash0-nodejs-autoinstrumentation/README.mdThe installed copy of this page
/usr/share/doc/dash0-nodejs-autoinstrumentation/copyrightThe license statement and the notice, DEB only
/usr/share/licenses/dash0-nodejs-autoinstrumentation/LICENSEThe license, RPM only
/usr/share/licenses/dash0-nodejs-autoinstrumentation/NOTICEThe 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

PackageRelationWhy
dash0-keyringDependsEvery Dash0 package depends on it, so the signing certificate is owned by a package that upgrades it
dash0-injectorSuggestsInstruments 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-autoinstrumentationConflicts, and Replaces on DEB or Obsoletes on RPMTakes 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-autoinstrumentation

On 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-autoinstrumentation

The 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

https://github.com/dash0hq/opentelemetry-js-distribution 

Last updated: