IngestionTracesOpentelemetry

OpenObserve Node.js Tracing Guide

Updated View MarkdownOpen in ChatGPTOpen in Claude

Send distributed traces from Node.js applications on Red Hat Enterprise Linux and Windows Server to OpenObserve through the OpenTelemetry Collector. No code changes are needed.

How to use this guide. Read Before you begin and fill in the table of values. Then follow Part A on Red Hat Enterprise Linux servers or Part B on Windows servers, one step at a time. Every value you must replace is shown in angle brackets, like <SERVICE_NAME>, and the steps that contain one are marked with ✏️. Everything else can be copied as it is. Each part ends with a check that your traces arrived in OpenObserve.

Contents

  1. Before you begin
  2. Part A: Red Hat Enterprise Linux
  3. Part B: Windows Server
  4. Troubleshooting
  5. Tested versions

Before you begin

This guide sends distributed traces from a Node.js application to OpenObserve. No code changes are needed: OpenTelemetry's Node.js auto-instrumentation traces http/https, Express, Fastify, NestJS, Koa, pg, mysql, MongoDB, Redis, gRPC, the AWS SDK and other common modules.

Node.js trace data path: application, OpenTelemetry Collector, OpenObserve

The application sends traces to an OpenTelemetry Collector on the same server. The Collector batches them, retries on network errors, and forwards them to OpenObserve. Only the Collector holds your OpenObserve credentials.

Which part to follow

Your serverFollowSteps
Red Hat Enterprise Linux 8 or 9Part AA1 Install the Collector → A2 Instrument the app → A3 Verify
Windows Server 2016 or laterPart BB1 Install the Collector → B2 Instrument the app → B3 Verify

Do all steps in order on each application server. Allow about 20 minutes per server.

Values you need to provide

Throughout this guide, every value in angle brackets, like <SERVICE_NAME>, is a value you must replace with your own. Replace the angle brackets too. Copy everything else exactly as shown. Fill in this table before you start:

PlaceholderWhat to enterWhere to find itExample
<OPENOBSERVE_URL>Base URL of your OpenObserve, with no trailing /OpenObserve Cloud: https://api.openobserve.ai. Self-hosted: the URL you use to open OpenObservehttps://o2.example.com
<ORG_ID>Your OpenObserve organization IDOpenObserve → Data sources. It's part of the endpoint shown theredefault
<BASE64_CREDENTIALS>Base64 of email:password-or-token for the ingestion userOpenObserve → Data sources shows a ready-made Authorization: Basic ... value; use the part after Basic . To build it yourself, see the note belowdXNlcjpwYXNz
<TRACE_STREAM>Traces stream to write toYour choice. It is created on first usedefault
<SERVICE_NAME>Name this application will have in OpenObserveYour choice. Lowercase, unique per applicationcheckout-api
<ENVIRONMENT>Environment labelYour choiceproduction
<SERVICE_VERSION>Application version labelYour release version2.3.1
<APP_DIR>The application folder that contains package.json and node_modulesYour serverRHEL: /opt/checkout · Windows: C:\apps\checkout
<APP_UNIT>systemd service name of the application (RHEL)systemctl list-units --type=servicecheckout
<WINDOWS_SERVICE>Windows service name of the application (Windows)Get-ServiceCheckoutApi
<APP_URL>A URL of the application for a test requestYour applicationhttp://localhost:3000/health
<O2_USER_EMAIL> / <O2_PASSWORD_OR_TOKEN>An OpenObserve login, used only for the optional API check in step A3/B3OpenObserveingest@example.com

To build <BASE64_CREDENTIALS> yourself:

  • RHEL: echo -n '<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>' | base64
  • Windows PowerShell: [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes('<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>'))

Use a dedicated OpenObserve user or service account for ingestion, not a personal administrator login.

Prerequisites

  • Administrator rights on the server: sudo on RHEL, an elevated PowerShell on Windows.
  • Node.js 18.19 or later, and npm.
  • Outbound HTTPS (port 443) from the server to <OPENOBSERVE_URL>. Self-hosted OpenObserve may use port 5080 instead.
  • Internet access to github.com and registry.npmjs.org. Without it, use your internal npm registry.
  • A short restart window for the application. Instrumentation loads at startup.

Auto-instrumentation or eBPF?

On Red Hat Enterprise Linux, you can also trace Node.js applications with eBPF instead of the npm packages in this guide. One OBI service per server traces every application on it from the kernel, with no packages to install and no change to the applications. See the companion OpenObserve eBPF Tracing Guide.

UseWhen
Auto-instrumentation (this guide)You need framework detail (Express middleware and routes, database statements, exceptions, custom spans), the server runs Windows, or you can't run a root-level service
eBPFYou want broad coverage quickly, can't add npm packages or change NODE_OPTIONS, or also run services with no agent (Go, Rust, C/C++, web servers)

In testing, eBPF traced the Node.js sample application (Express) with complete linking: incoming request, outgoing call and downstream request in one trace. Both methods can run on the same server. OBI automatically skips applications that use the auto-instrumentation.

Part A: Red Hat Enterprise Linux

Run every command as a user with sudo rights on the application server. Commands without placeholders can be copied as they are.

Step A1. Install and configure the OpenTelemetry Collector

A1.1 Download the Collector package and verify its checksum. On ARM servers, set ARCH=arm64.

OTEL_VERSION=0.166.0
ARCH=amd64
BASE=https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}
cd /tmp
curl -LO ${BASE}/otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm
curl -LO ${BASE}/otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm.sha256
echo "$(cat otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm.sha256)  otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm" | sha256sum -c -

Expected output: otelcol-contrib_0.166.0_linux_amd64.rpm: OK

A1.2 Install the package. This creates the otelcol-contrib systemd service and the /etc/otelcol-contrib/ folder.

sudo dnf install -y ./otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm

A1.3 Write the Collector configuration. This file contains no values of yours; they come from the next step. Copy the whole block as it is.

sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.orig
sudo tee /etc/otelcol-contrib/config.yaml >/dev/null <<'EOF'
extensions:
  health_check:
    endpoint: 127.0.0.1:13133

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 127.0.0.1:4317
      http:
        endpoint: 127.0.0.1:4318

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 25
  resource_detection:
    detectors: [env, system]
    system:
      hostname_sources: [os]
  batch:
    send_batch_size: 1024
    timeout: 5s

exporters:
  otlp_http/openobserve:
    endpoint: ${env:O2_OTLP_ENDPOINT}
    headers:
      Authorization: "Basic ${env:O2_AUTH_TOKEN}"
      stream-name: ${env:O2_TRACE_STREAM}
    compression: gzip
    retry_on_failure:
      enabled: true
    sending_queue:
      enabled: true
      queue_size: 5000

service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resource_detection, batch]
      exporters: [otlp_http/openobserve]
EOF

The Collector listens only on 127.0.0.1, so only applications on this server can send to it. To accept traces from other servers too, change the two receiver endpoints to 0.0.0.0:4317 and 0.0.0.0:4318, and open those ports in the firewall (A1.6).

A1.4 Enter your OpenObserve values. ✏️ Replace the three placeholders, then run:

sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf >/dev/null <<'EOF'
O2_OTLP_ENDPOINT=<OPENOBSERVE_URL>/api/<ORG_ID>
O2_AUTH_TOKEN=<BASE64_CREDENTIALS>
O2_TRACE_STREAM=<TRACE_STREAM>
EOF
sudo chown root:otelcol-contrib /etc/otelcol-contrib/otelcol-contrib.conf
sudo chmod 640 /etc/otelcol-contrib/otelcol-contrib.conf

Filled in, the three lines look like this:

O2_OTLP_ENDPOINT=https://o2.example.com/api/default
O2_AUTH_TOKEN=dXNlcjpwYXNz
O2_TRACE_STREAM=default

Don't add /v1/traces to the endpoint; the Collector adds it. Don't add Basic to the token; the configuration adds it.

A1.5 Check the configuration, then start the Collector:

sudo bash -c 'set -a; . /etc/otelcol-contrib/otelcol-contrib.conf; otelcol-contrib validate --config=/etc/otelcol-contrib/config.yaml' && echo CONFIG OK
sudo systemctl enable otelcol-contrib
sudo systemctl restart otelcol-contrib
sudo systemctl status otelcol-contrib --no-pager
curl -s http://127.0.0.1:13133

Expected: CONFIG OK, status active (running), and {"status":"Server available",...}.

A1.6 (Only if other servers send to this Collector) Open the firewall:

sudo firewall-cmd --permanent --add-port=4317/tcp --add-port=4318/tcp
sudo firewall-cmd --reload

A1.7 Send a test trace from the Collector to OpenObserve. This confirms the connection and credentials before you touch the application.

NOW=$(date +%s); TID=$(openssl rand -hex 16); SID=$(openssl rand -hex 8)
curl -s -w ' HTTP %{http_code}\n' -X POST http://127.0.0.1:4318/v1/traces -H 'Content-Type: application/json' -d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"collector-smoke-test"}}]},"scopeSpans":[{"spans":[{"traceId":"'$TID'","spanId":"'$SID'","name":"smoke-test","kind":1,"startTimeUnixNano":"'${NOW}000000000'","endTimeUnixNano":"'${NOW}500000000'"}]}]}]}'

Expected: {"partialSuccess":{}} HTTP 200. Within about 10 seconds, a service named collector-smoke-test appears under Traces in OpenObserve. If it doesn't, check sudo journalctl -u otelcol-contrib -n 50 --no-pager and see Troubleshooting.

Step A2. Instrument the Node.js application

A2.1 Add the OpenTelemetry packages to the application. ✏️ Replace <APP_DIR>. Run this as the user who owns the application files.

cd <APP_DIR>
npm install --save @opentelemetry/api @opentelemetry/auto-instrumentations-node

Commit the updated package.json and package-lock.json, so that your normal deployment installs the same packages.

A2.2 Create the tracing settings file for the application. ✏️ Replace <APP_UNIT>, <APP_DIR>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>:

sudo tee /etc/sysconfig/<APP_UNIT>-otel >/dev/null <<'EOF'
NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
NODE_PATH=<APP_DIR>/node_modules
OTEL_SERVICE_NAME=<SERVICE_NAME>
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=none
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
OTEL_NODE_RESOURCE_DETECTORS=env,host,os,process
EOF

NODE_OPTIONS loads the instrumentation before your application code, so you don't need to change the start command. NODE_PATH lets Node.js find the package even when the service starts in a different folder. If the service already sets NODE_OPTIONS (for example --max-old-space-size=4096), put both in the same line: NODE_OPTIONS="--max-old-space-size=4096 --require @opentelemetry/auto-instrumentations-node/register".

For ES-module applications ("type": "module" in package.json), use --import instead of --require in NODE_OPTIONS.

A2.3 Attach the settings to the application's service. ✏️ Replace <APP_UNIT> in both places:

sudo mkdir -p /etc/systemd/system/<APP_UNIT>.service.d
sudo tee /etc/systemd/system/<APP_UNIT>.service.d/otel.conf >/dev/null <<'EOF'
[Service]
EnvironmentFile=/etc/sysconfig/<APP_UNIT>-otel
EOF

If the application runs under PM2 instead of systemd, add the same values to the env section of the app in ecosystem.config.js, then run pm2 restart ecosystem.config.js --update-env.

A2.4 Restart the application and confirm the settings are active. ✏️ Replace <APP_UNIT> and <APP_URL>:

sudo systemctl daemon-reload
sudo systemctl restart <APP_UNIT>
sudo systemctl status <APP_UNIT> --no-pager
sudo cat /proc/$(systemctl show -p MainPID --value <APP_UNIT>)/environ | tr '\0' '\n' | grep -E '^(NODE_OPTIONS|OTEL_SERVICE_NAME)='
curl -s <APP_URL> > /dev/null

Expected: the service is active (running), and the last-but-one command prints your NODE_OPTIONS and OTEL_SERVICE_NAME. If the service fails with Cannot find module '@opentelemetry/auto-instrumentations-node/register', check NODE_PATH and repeat A2.1.

Step A3. Verify traces in OpenObserve

  1. Send a few requests to the application, or wait for normal traffic.
  2. In OpenObserve, open Traces, select the <TRACE_STREAM> stream and the Last 15 minutes time range.
  3. Filter on service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds.
  4. Open a trace. It shows the incoming request (for example GET /orders) with child spans for middleware, database queries and outgoing HTTP calls. Calls to other instrumented services appear in the same trace.

Optional check from the command line. ✏️ Replace the placeholders:

END=$(($(date +%s)*1000000)); START=$((END-3600*1000000))
cat > /tmp/q.json <<EOF
{"query":{"sql":"SELECT service_name, count(*) AS spans FROM \"<TRACE_STREAM>\" GROUP BY service_name","start_time":$START,"end_time":$END}}
EOF
curl -s -u '<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>' -H 'Content-Type: application/json' \
  "<OPENOBSERVE_URL>/api/<ORG_ID>/_search?type=traces" -d @/tmp/q.json

Expected: a hits list that includes <SERVICE_NAME> with a span count above 0.

Repeat Part A on every RHEL application server. Use a different <SERVICE_NAME> for each application, but the same name for every server that runs the same application.

Part B: Windows Server

Run every command in PowerShell as Administrator on the application server. Commands without placeholders can be copied as they are.

Step B1. Install and configure the OpenTelemetry Collector

B1.1 Download the Collector installer and verify its checksum:

$v = '0.166.0'
$base = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$v"
$msi = "otelcol-contrib_${v}_windows_x64.msi"
New-Item -ItemType Directory -Force C:\temp | Out-Null; Set-Location C:\temp
Invoke-WebRequest "$base/$msi" -OutFile $msi
Invoke-WebRequest "$base/$msi.sha256" -OutFile "$msi.sha256"
$expected = (Get-Content "$msi.sha256" -Raw).Trim().Split(' ')[0]
if ((Get-FileHash $msi -Algorithm SHA256).Hash -ne $expected.ToUpper()) { throw 'Checksum mismatch - do not install' } else { 'Checksum OK' }

B1.2 Install the Collector. This creates the Windows service otelcol-contrib (automatic start) and the folder C:\Program Files\OpenTelemetry Collector\.

Start-Process msiexec.exe -Wait -ArgumentList "/i `"C:\temp\$msi`" /qn /l*v C:\temp\otelcol-install.log"
Get-Service otelcol-contrib

B1.3 Write the Collector configuration. This file contains no values of yours; they come from the next step. Copy the whole block as it is.

$dir = 'C:\Program Files\OpenTelemetry Collector'
Copy-Item "$dir\config.yaml" "$dir\config.yaml.orig" -Force
@'
extensions:
  health_check:
    endpoint: 127.0.0.1:13133

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 127.0.0.1:4317
      http:
        endpoint: 127.0.0.1:4318

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 25
  resource_detection:
    detectors: [env, system]
    system:
      hostname_sources: [os]
  batch:
    send_batch_size: 1024
    timeout: 5s

exporters:
  otlp_http/openobserve:
    endpoint: ${env:O2_OTLP_ENDPOINT}
    headers:
      Authorization: "Basic ${env:O2_AUTH_TOKEN}"
      stream-name: ${env:O2_TRACE_STREAM}
    compression: gzip
    retry_on_failure:
      enabled: true
    sending_queue:
      enabled: true
      queue_size: 5000

service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resource_detection, batch]
      exporters: [otlp_http/openobserve]
'@ | Set-Content -Path "$dir\config.yaml" -Encoding ascii

To accept traces from other servers too, change the two receiver endpoints to 0.0.0.0:4317 and 0.0.0.0:4318, and open the firewall (B1.6).

B1.4 Enter your OpenObserve values. ✏️ Replace the three placeholders, then run. The values are stored on the Collector service only; other programs can't see them.

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\otelcol-contrib' -Name Environment -Type MultiString -Value @(
  'O2_OTLP_ENDPOINT=<OPENOBSERVE_URL>/api/<ORG_ID>',
  'O2_AUTH_TOKEN=<BASE64_CREDENTIALS>',
  'O2_TRACE_STREAM=<TRACE_STREAM>'
)

Filled in, the first line looks like 'O2_OTLP_ENDPOINT=https://o2.example.com/api/default',. Don't add /v1/traces or Basic .

B1.5 Check the configuration, then restart the Collector. ✏️ Use the same three values as in B1.4:

$env:O2_OTLP_ENDPOINT = '<OPENOBSERVE_URL>/api/<ORG_ID>'; $env:O2_AUTH_TOKEN = '<BASE64_CREDENTIALS>'; $env:O2_TRACE_STREAM = '<TRACE_STREAM>'
& 'C:\Program Files\OpenTelemetry Collector\otelcol-contrib.exe' validate --config 'C:\Program Files\OpenTelemetry Collector\config.yaml'; if ($LASTEXITCODE -eq 0) { 'CONFIG OK' }
Restart-Service otelcol-contrib
Get-Service otelcol-contrib
(Invoke-WebRequest http://127.0.0.1:13133 -UseBasicParsing).Content

Expected: CONFIG OK, status Running, and {"status":"Server available",...}.

B1.6 (Only if other servers send to this Collector) Open the firewall:

New-NetFirewallRule -DisplayName 'OpenTelemetry Collector OTLP' -Direction Inbound -Protocol TCP -LocalPort 4317,4318 -Action Allow

B1.7 Send a test trace from the Collector to OpenObserve:

$now = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$tid = -join ((1..32) | % { '{0:x}' -f (Get-Random -Max 16) }); $sid = -join ((1..16) | % { '{0:x}' -f (Get-Random -Max 16) })
$body = '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"collector-smoke-test"}}]},"scopeSpans":[{"spans":[{"traceId":"' + $tid + '","spanId":"' + $sid + '","name":"smoke-test","kind":1,"startTimeUnixNano":"' + ($now*1000000) + '","endTimeUnixNano":"' + (($now+500)*1000000) + '"}]}]}]}'
$r = Invoke-WebRequest -Uri http://127.0.0.1:4318/v1/traces -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
"HTTP $($r.StatusCode) $($r.Content)"

Expected: HTTP 200 {"partialSuccess":{}}. Within about 10 seconds, the service collector-smoke-test appears under Traces in OpenObserve. Collector messages are in Event Viewer → Windows Logs → Application; filter on source otelcol-contrib.

Step B2. Instrument the Node.js application

B2.1 Add the OpenTelemetry packages to the application. ✏️ Replace <APP_DIR>:

Set-Location '<APP_DIR>'
npm install --save @opentelemetry/api @opentelemetry/auto-instrumentations-node

Commit the updated package.json and package-lock.json, so that your normal deployment installs the same packages.

B2.2 Add the tracing settings to the application's Windows service. ✏️ Replace <WINDOWS_SERVICE>, <APP_DIR>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>. Existing service settings are kept.

$svc = '<WINDOWS_SERVICE>'
$key = "HKLM:\SYSTEM\CurrentControlSet\Services\$svc"
$current = @((Get-ItemProperty $key -Name Environment -ErrorAction SilentlyContinue).Environment | Where-Object { $_ })
$otel = @(
  'NODE_OPTIONS=--require @opentelemetry/auto-instrumentations-node/register',
  'NODE_PATH=<APP_DIR>\node_modules',
  'OTEL_SERVICE_NAME=<SERVICE_NAME>',
  'OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>',
  'OTEL_TRACES_EXPORTER=otlp',
  'OTEL_METRICS_EXPORTER=none',
  'OTEL_LOGS_EXPORTER=none',
  'OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf',
  'OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318',
  'OTEL_NODE_RESOURCE_DETECTORS=env,host,os,process'
)
Set-ItemProperty $key -Name Environment -Type MultiString -Value ($current + $otel)
(Get-ItemProperty $key).Environment

This works with any service wrapper: NSSM, WinSW, node-windows or PM2 as a service. Set these values on the application's service only. Don't set NODE_OPTIONS as a machine-wide variable: every Node.js program on the server, including npm, would load the instrumentation. If the service already sets NODE_OPTIONS, combine both into one entry, for example NODE_OPTIONS=--max-old-space-size=4096 --require @opentelemetry/auto-instrumentations-node/register.

For a quick test from a console. ✏️ Replace the placeholders and your usual start command:

Set-Location '<APP_DIR>'
$env:NODE_OPTIONS = '--require @opentelemetry/auto-instrumentations-node/register'
$env:OTEL_SERVICE_NAME = '<SERVICE_NAME>'
$env:OTEL_RESOURCE_ATTRIBUTES = 'deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>'
$env:OTEL_TRACES_EXPORTER = 'otlp'; $env:OTEL_METRICS_EXPORTER = 'none'; $env:OTEL_LOGS_EXPORTER = 'none'
$env:OTEL_EXPORTER_OTLP_PROTOCOL = 'http/protobuf'; $env:OTEL_EXPORTER_OTLP_ENDPOINT = 'http://127.0.0.1:4318'
node app.js     # your usual start command

B2.3 Restart the application and send a request. ✏️ Replace <WINDOWS_SERVICE> and <APP_URL>:

Restart-Service '<WINDOWS_SERVICE>'
Invoke-WebRequest '<APP_URL>' -UseBasicParsing | Out-Null

If the service stops right after starting, check its log for Cannot find module '@opentelemetry/auto-instrumentations-node/register'. That means NODE_PATH doesn't point to the application's node_modules folder.

Step B3. Verify traces in OpenObserve

  1. Send a few requests to the application, or wait for normal traffic.
  2. In OpenObserve, open Traces, select the <TRACE_STREAM> stream and the Last 15 minutes time range.
  3. Filter on service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds.
  4. Open a trace. It shows the incoming request with child spans for middleware, database queries and outgoing HTTP calls.

Optional check from PowerShell. ✏️ Replace the placeholders:

$end = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() * 1000; $start = $end - 3600000000
$body = @{ query = @{ sql = 'SELECT service_name, count(*) AS spans FROM "<TRACE_STREAM>" GROUP BY service_name'; start_time = $start; end_time = $end } } | ConvertTo-Json
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes('<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>'))
(Invoke-RestMethod -Method Post -Uri '<OPENOBSERVE_URL>/api/<ORG_ID>/_search?type=traces' -Headers @{ Authorization = "Basic $auth" } -ContentType 'application/json' -Body $body).hits

Expected: a row for <SERVICE_NAME> with a span count above 0.

Repeat Part B on every Windows application server.

Troubleshooting

Start with the Collector test trace (A1.7 / B1.7). If collector-smoke-test reaches OpenObserve, the connection to OpenObserve is fine, and the problem is between the application and the Collector. If it doesn't arrive, fix the Collector first.

Where to look:

  • Collector log. RHEL: sudo journalctl -u otelcol-contrib -n 100 --no-pager. Windows: Event Viewer → Windows Logs → Application, source otelcol-contrib.
  • Application log. Set OTEL_LOG_LEVEL=debug in the application settings for a short time to see OpenTelemetry messages in the application's output.
SymptomCauseFix
Application won't start: Cannot find module '@opentelemetry/auto-instrumentations-node/register'NODE_PATH doesn't point to the folder where the package is installedSet NODE_PATH to <APP_DIR>/node_modules (Windows: <APP_DIR>\node_modules) and check that A2.1 / B2.1 ran in that folder
Application runs, but no traces arriveThe settings aren't attached to the serviceRHEL: systemctl cat <APP_UNIT> must show otel.conf, and A2.4 must print NODE_OPTIONS. Windows: check the service's Environment (B2.2)
Incoming requests traced, but no database or HTTP-client spansThose modules were loaded before the instrumentation, or the app is an ES moduleLoad the instrumentation through NODE_OPTIONS as shown, not from inside the code. For ES modules, use --import
Too many small spans (middleware - ..., fs, dns)Detailed instrumentations are on by defaultAdd OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs,dns,net to the application settings
npm or other Node.js tools print OpenTelemetry messagesNODE_OPTIONS was set machine-wideRemove it from the system environment and set it only on the application's service
Collector log shows 401 or 403Wrong <BASE64_CREDENTIALS>, or the user has no access to <ORG_ID>Rebuild the Base64 value from email:password-or-token and check the org ID. Restart the Collector
Collector log shows 404Wrong endpoint pathO2_OTLP_ENDPOINT must be <OPENOBSERVE_URL>/api/<ORG_ID>, without /v1/traces
Collector log shows connection refused, a timeout, or a TLS errorNo network route or a proxy in betweenTest with curl -I <OPENOBSERVE_URL>. If you need a proxy, add HTTPS_PROXY=http://<proxy-host>:<port> next to the other O2_* values
Application logs errors exporting metrics or logsOTEL_METRICS_EXPORTER / OTEL_LOGS_EXPORTER missingSet both to none; this setup collects traces only
Calls between services show as separate tracesA proxy or API gateway removes the traceparent headerConfigure it to forward the traceparent and tracestate headers
Too much trace volumeEvery request is tracedAdd OTEL_TRACES_SAMPLER=parentbased_traceidratio and OTEL_TRACES_SAMPLER_ARG=0.1 (10%) to the application settings

To remove tracing, delete the settings: on RHEL, the files from A2.2 and A2.3; on Windows, the NODE_OPTIONS, NODE_PATH and OTEL_* entries from B2.2. Then restart the application. The installed packages do nothing without these settings.

Tested versions

This procedure was tested end to end on Red Hat Enterprise Linux 9.9 and Windows Server 2022 with the versions below. Other versions usually work. Before upgrading a component, check its release notes for removed settings.

ComponentVersion
OpenTelemetry Collector Contrib0.166.0
@opentelemetry/auto-instrumentations-node0.83.1
@opentelemetry/api1.10.0
Node.js22.23 (RHEL nodejs:22 module), 22.23.5 (Windows)
FrameworkExpress 4.21 with fetch
OpenObservev1.2.0

For the full list of auto-instrumented modules, see auto-instrumentations-node.

Was this page helpful?