Dash0 OpenTelemetry distribution wrapper for Node.js with automatic instrumentation and configuration via environment variables
npx @tessl/cli install tessl/npm-dash0--opentelemetry@3.0.0Side-effect auto-initialization package for Node.js OpenTelemetry instrumentation. No programmatic API - configures via environment variables only.
@dash0/opentelemetrynpm install @dash0/opentelemetryLoad via Node.js require flag or at application entry point:
node --require @dash0/opentelemetry app.jsrequire('@dash0/opentelemetry');
// Rest of application codeAutomatically initializes OpenTelemetry SDK with OTLP exporters for traces, metrics, and logs.
// DASH0_OTEL_COLLECTOR_BASE_URL (REQUIRED)
// Type: string (URL)
// Description: Base URL of OpenTelemetry collector
// Endpoints: ${url}/v1/traces, ${url}/v1/metrics, ${url}/v1/logs
// Example: "http://collector.example.com:4318"Initialization fails without this variable set.
| Variable | Type | Default | Description |
|---|---|---|---|
DASH0_DISABLE | "true"|"false" | not set | Completely disables the distribution |
DASH0_DEBUG | "true"|"false" | "false" | Enables debug logs to console |
DASH0_DEBUG_PRINT_SPANS | "true"|string | not set | Prints spans to stdout ("true") or file path (for debugging only) |
| Variable | Type | Default | Description |
|---|---|---|---|
DASH0_AUTOMATIC_SERVICE_NAME | "true"|"false" | "true" | Auto-detect service.name and service.version from package.json |
OTEL_SERVICE_NAME | string | auto-detected | Explicit service name (highest precedence) |
OTEL_RESOURCE_ATTRIBUTES | string | - | Comma-separated key=value pairs (can include service.name) |
Service Name Precedence (highest to lowest):
OTEL_SERVICE_NAMEservice.name in OTEL_RESOURCE_ATTRIBUTESDASH0_AUTOMATIC_SERVICE_NAME != "false")| Variable | Type | Default | Description |
|---|---|---|---|
DASH0_BOOTSTRAP_SPAN | string | not set | Creates startup span with specified name |
DASH0_FLUSH_ON_SIGTERM_SIGINT | "true"|"false" | "false" | Install SIGTERM/SIGINT handlers (500ms timeout). Do not use with custom signal handlers |
DASH0_FLUSH_ON_EMPTY_EVENT_LOOP | "true"|"false" | "true" | Flush on beforeExit event (500ms timeout) |
| Variable | Type | Default | Description |
|---|---|---|---|
DASH0_ENABLE_FS_INSTRUMENTATION | "true"|"false" | "false" | Enable @opentelemetry/instrumentation-fs (high span volume) |
OTEL_NODE_ENABLED_INSTRUMENTATIONS | string | all enabled | Comma-separated list (without @opentelemetry/instrumentation- prefix) |
Available instrumentations: http, https, express, fastify, graphql, grpc, ioredis, kafkajs, mongodb, mysql, mysql2, nestjs-core, pg, redis, and more. See OpenTelemetry docs.
Example: OTEL_NODE_ENABLED_INSTRUMENTATIONS=http,express,pg
| Variable | Type | Default | Description |
|---|---|---|---|
OTEL_NODE_RESOURCE_DETECTORS | string | env,process,container,host | Comma-separated detector list |
Built-in detectors: env, process, container, host
Dash0-specific (always added): podUid, serviceNameFallback
| Variable | Type | Default | Description |
|---|---|---|---|
OTEL_METRIC_EXPORT_INTERVAL | number (ms) | 60000 | Metric export interval |
OTEL_METRIC_EXPORT_TIMEOUT | number (ms) | 30000 | Metric export timeout |
Always added to all telemetry:
{
'telemetry.distro.name': 'dash0-nodejs',
'telemetry.distro.version': string, // From package.json
'service.name': string, // If auto-detection enabled
'service.version': string, // If auto-detection enabled
'k8s.pod.uid': string, // When running in Kubernetes
// Standard OpenTelemetry attributes from resource detectors
}Pod UID Detection: Reads from /proc/self/mountinfo (cgroup v1) or /proc/self/cgroup (cgroup v2) when /etc/hosts indicates Kubernetes environment.
Automatically selects OpenTelemetry SDK based on Node.js version:
Protocol: OTLP over HTTP with Protocol Buffers
Processors:
BatchSpanProcessorPeriodicExportingMetricReaderBatchLogRecordProcessorEndpoints:
${DASH0_OTEL_COLLECTOR_BASE_URL}/v1/traces${DASH0_OTEL_COLLECTOR_BASE_URL}/v1/metrics${DASH0_OTEL_COLLECTOR_BASE_URL}/v1/logsInitialization fails and logs to stderr:
DASH0_DISABLE=true → "Distribution has been disabled"DASH0_OTEL_COLLECTOR_BASE_URL not set → "DASH0_OTEL_COLLECTOR_BASE_URL is not set"Behavior on failure: Application continues normally, no telemetry collected.
# Required
export DASH0_OTEL_COLLECTOR_BASE_URL=http://collector.example.com:4318
# Optional overrides
export OTEL_SERVICE_NAME=my-service
export OTEL_RESOURCE_ATTRIBUTES=environment=production,team=backend
# Selective instrumentation
export OTEL_NODE_ENABLED_INSTRUMENTATIONS=http,express,pg,redis
# Graceful shutdown
export DASH0_FLUSH_ON_EMPTY_EVENT_LOOP=true
# Start with instrumentation
node --require @dash0/opentelemetry app.jsenv:
- name: NODE_OPTIONS
value: "--require @dash0/opentelemetry"
- name: DASH0_OTEL_COLLECTOR_BASE_URL
value: "http://collector.dash0-system.svc.cluster.local:4318"