Configuration

All Dash0-specific and standard OpenTelemetry environment variables for the Node.js distribution, including context propagation.

The distribution is configured with environment variables. Alternatively, the OpenTelemetry SDK can be configured with a declarative configuration file; this page notes which settings still apply in that case.

Dash0-specific environment variables

VariableDefaultDescription
DASH0_OTEL_COLLECTOR_BASE_URLnoneBase URL of the collector that telemetry is sent to.
DASH0_DISABLEfalseDisables the distribution entirely.
DASH0_AUTOMATIC_SERVICE_NAMEtrueDerives the service name and version from package.json.
DASH0_BOOTSTRAP_SPANnoneEmits a span with this name at startup.
DASH0_DEBUGfalsePrints debug log output.
DASH0_DEBUG_PRINT_SPANSfalsePrints all spans to stdout.
DASH0_ENABLE_FS_INSTRUMENTATIONfalseEnables spans for file system access.
DASH0_FLUSH_ON_EMPTY_EVENT_LOOPtrueFlushes telemetry when the event loop is empty.
DASH0_FLUSH_ON_SIGTERM_SIGINTfalseFlushes telemetry on SIGTERM and SIGINT.

DASH0_OTEL_COLLECTOR_BASE_URL

The base URL of the OpenTelemetry collector that the distribution sends data to, for example http://localhost:4318. The distribution appends /v1/traces, /v1/metrics and /v1/logs to it.

This variable is required unless a declarative configuration file is used. Without either, the distribution does not start. When both are set, the configuration file takes precedence, and DASH0_OTEL_COLLECTOR_BASE_URL sets the default for OTEL_EXPORTER_OTLP_ENDPOINT, without trailing slashes. A file that references ${OTEL_EXPORTER_OTLP_ENDPOINT} then exports to that collector. An explicitly set OTEL_EXPORTER_OTLP_ENDPOINT takes precedence.

DASH0_DISABLE

Set DASH0_DISABLE=true to disable the Dash0 Node.js distribution entirely.

DASH0_AUTOMATIC_SERVICE_NAME

If no service name has been set, a service name and a service version are automatically derived from the application's main package.json file, if it is present:

  • The service.name resource attribute is set to the value of the name attribute in package.json.
  • The service.version resource attribute is set to the value of the version attribute in package.json.

This behavior is disabled in any of these cases:

  • An explicit service name is set with the OTEL_SERVICE_NAME environment variable.
  • An explicit service name is set with the OTEL_RESOURCE_ATTRIBUTES environment variable, using the service.name attribute key.
  • The environment variable DASH0_AUTOMATIC_SERVICE_NAME=false is set.

With a configuration file, use the dash0_service_name resource detector instead (see Resource detection).

DASH0_BOOTSTRAP_SPAN

If set, the distribution creates a span immediately at startup, with the span name set to the value of DASH0_BOOTSTRAP_SPAN.

DASH0_DEBUG

Set DASH0_DEBUG=true to enable additional debug log output.

DASH0_DEBUG_PRINT_SPANS

If DASH0_DEBUG_PRINT_SPANS=true is set, all spans are printed to stdout via the ConsoleSpanExporter .

With a configuration file, add a span processor with a console exporter to the file instead.

DASH0_ENABLE_FS_INSTRUMENTATION

By default, the instrumentation @opentelemetry/instrumentation-fs is disabled. Set DASH0_ENABLE_FS_INSTRUMENTATION=true to enable spans for file system access.

DASH0_FLUSH_ON_EMPTY_EVENT_LOOP

By default, the distribution installs a hook that shuts down the OpenTelemetry SDK gracefully when the Node.js runtime is about to exit because the event loop is empty. This can be disabled by setting DASH0_FLUSH_ON_EMPTY_EVENT_LOOP=false. The SDK shutdown is timeboxed to 500 milliseconds.

This hook can be helpful if you care about telemetry that is produced shortly before the process exits. Disabling it can be useful if you care about the process terminating as quickly as possible when the event loop is empty. Unlike the handlers for SIGTERM and SIGINT (see below), this hook does not re-raise a signal. If the SDK shutdown completes within the timeout, the Node.js runtime exits on its own afterwards. If it times out, the distribution calls process.exit(). Either way, the process exits with the exit code set in process.exitCode, if any.

DASH0_FLUSH_ON_SIGTERM_SIGINT

If DASH0_FLUSH_ON_SIGTERM_SIGINT=true is set, the distribution installs a handler for SIGTERM and SIGINT that shuts down the OpenTelemetry SDK gracefully when one of these signals is received. The SDK shutdown is timeboxed to 500 milliseconds. After the SDK shutdown has completed, or after the 500 millisecond timeout, whichever happens sooner, the signal handler re-raises the signal, so the process terminates with the signal's default behavior.

This option can be helpful if you care about telemetry that is produced shortly before the process terminates. Do not use this option if the application has its own handler for SIGTERM or SIGINT, because the distribution's handler, and in particular re-raising the signal, might interfere with the application's own signal handler.

Standard OpenTelemetry environment variables

Without a configuration file, the OTEL_* environment variables that the upstream NodeSDK reads work as documented by the upstream project, for example:

  • OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES for resource attributes.
  • OTEL_EXPORTER_OTLP_HEADERS for headers, such as an authorization header, sent with every export request.
  • OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG for sampling.
  • OTEL_NODE_RESOURCE_DETECTORS to select resource detectors (see Resource detection).

The distribution also reads these variables itself:

VariableDefaultDescription
OTEL_METRIC_EXPORT_INTERVAL60000Interval between metric exports, in milliseconds.
OTEL_METRIC_EXPORT_TIMEOUT30000Timeout for a metric export, in milliseconds.
OTEL_PROPAGATORStracecontext,baggage,xrayContext propagation formats.
OTEL_NODE_ENABLED_INSTRUMENTATIONSallEnables only the listed instrumentations.

With a configuration file, set interval and timeout on the periodic metric reader in the file instead of OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT.

Context propagation

On Node.js 18.19.0 to 18.x and on 20.6.0 or newer, which use the OpenTelemetry JS SDK 2.x, the distribution uses tracecontext,baggage,xray if OTEL_PROPAGATORS is not set: W3C Trace Context, W3C Baggage and AWS X-Ray (X-Amzn-Trace-Id). Outgoing requests carry both traceparent and X-Amzn-Trace-Id. If an incoming request carries a valid X-Amzn-Trace-Id (with Root, Parent and Sampled), it takes precedence over traceparent. An X-Amzn-Trace-Id without Parent, as added by an AWS load balancer to requests that arrive without one, is ignored, so the trace continues from traceparent.

Setting OTEL_PROPAGATORS replaces the default. In addition to the values supported by the OpenTelemetry SDK (tracecontext, baggage, b3, b3multi, jaeger, none), the distribution supports xray, xray-lambda and ottrace via @opentelemetry/auto-configuration-propagators . For example, set OTEL_PROPAGATORS=tracecontext,baggage to turn off X-Ray propagation.

On Node.js 16.x to 18.18.x and 20.0.0 to 20.5.x, which use the OpenTelemetry JS SDK 1.x, the distribution uses the SDK's default (tracecontext,baggage) and does not support xray.

With a configuration file, configure propagators in the file (see Declarative configuration).

Last updated: