OpenObserve Python Tracing Guide
Send distributed traces from Python 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
- Before you begin
- Part A: Red Hat Enterprise Linux
- Part B: Windows Server
- Troubleshooting
- Tested versions
Before you begin
This guide sends distributed traces from a Python application to OpenObserve. No code changes are needed: OpenTelemetry's Python auto-instrumentation traces Flask, Django, FastAPI, requests, httpx, psycopg, SQLAlchemy, Celery and other common libraries automatically.
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 server | Follow | Steps |
|---|---|---|
| Red Hat Enterprise Linux 8 or 9 | Part A | A1 Install the Collector → A2 Instrument the app → A3 Verify |
| Windows Server 2016 or later | Part B | B1 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:
| Placeholder | What to enter | Where to find it | Example |
|---|---|---|---|
<OPENOBSERVE_URL> | Base URL of your OpenObserve, with no trailing / | OpenObserve Cloud: https://api.openobserve.ai. Self-hosted: the URL you use to open OpenObserve | https://o2.example.com |
<ORG_ID> | Your OpenObserve organization ID | OpenObserve → Data sources. It's part of the endpoint shown there | default |
<BASE64_CREDENTIALS> | Base64 of email:password-or-token for the ingestion user | OpenObserve → Data sources shows a ready-made Authorization: Basic ... value; use the part after Basic . To build it yourself, see the note below | dXNlcjpwYXNz |
<TRACE_STREAM> | Traces stream to write to | Your choice. It is created on first use | default |
<SERVICE_NAME> | Name this application will have in OpenObserve | Your choice. Lowercase, unique per application | checkout-api |
<ENVIRONMENT> | Environment label | Your choice | production |
<SERVICE_VERSION> | Application version label | Your release version | 2.3.1 |
<VENV_DIR> | Full path to the application's Python virtual environment | The folder that contains bin/python (RHEL) or Scripts\python.exe (Windows) | RHEL: /opt/checkout/venv · Windows: C:\apps\checkout\venv |
<APP_UNIT> | systemd service name of the application (RHEL) | systemctl list-units --type=service | checkout |
<WINDOWS_SERVICE> | Windows service name of the application (Windows) | Get-Service | CheckoutApi |
<APP_URL> | A URL of the application for a test request | Your application | http://localhost:8000/health |
<O2_USER_EMAIL> / <O2_PASSWORD_OR_TOKEN> | An OpenObserve login, used only for the optional API check in step A3/B3 | OpenObserve | ingest@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:
sudoon RHEL, an elevated PowerShell on Windows. - Python 3.9 or later. The application must run from a virtual environment (
<VENV_DIR>). If it uses the system Python, create a virtual environment for it first. - Outbound HTTPS (port 443) from the server to
<OPENOBSERVE_URL>. Self-hosted OpenObserve may use port 5080 instead. - Internet access to
github.comandpypi.org. Without it, use your internal mirror or copy the files over. - A short restart window for the application. Instrumentation loads at startup.
Auto-instrumentation or eBPF?
On Red Hat Enterprise Linux, you can also trace Python applications with eBPF instead of the auto-instrumentation 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.
| Use | When |
|---|---|
| Auto-instrumentation (this guide) | You need framework detail (Flask/Django views, SQL statements, exceptions, custom spans), the server runs Windows, or you can't run a root-level service |
| eBPF | You want broad coverage quickly, can't add packages to the virtual environment, or also run services with no agent (Go, Rust, C/C++, web servers) |
In testing, eBPF traced the Python sample application (gunicorn) 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}.rpmA1.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]
EOFThe 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.confFilled in, the three lines look like this:
O2_OTLP_ENDPOINT=https://o2.example.com/api/default
O2_AUTH_TOKEN=dXNlcjpwYXNz
O2_TRACE_STREAM=defaultDon'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:13133Expected: 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 --reloadA1.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 Python application
A2.1 Install the OpenTelemetry packages into the application's virtual environment. ✏️ Replace <VENV_DIR>. Run this as the user who owns the virtual environment; prefix the last two commands with sudo if root owns it.
VENV=<VENV_DIR>
$VENV/bin/pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-http
$VENV/bin/opentelemetry-bootstrap -a installopentelemetry-bootstrap adds an instrumentation package for each supported library it finds in the environment, such as Flask, Django, requests or psycopg. Run it again after you add new libraries to the application.
A2.2 Create the tracing settings file for the application. ✏️ Replace <VENV_DIR>, <APP_UNIT>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>. The first command finds the folder that switches tracing on, and the file records it in PYTHONPATH.
VENV=<VENV_DIR>
AUTO_DIR=$($VENV/bin/python -c 'import os, opentelemetry.instrumentation.auto_instrumentation as m; print(os.path.dirname(m.__file__))')
echo "$AUTO_DIR"
sudo tee /etc/sysconfig/<APP_UNIT>-otel >/dev/null <<EOF
PYTHONPATH=${AUTO_DIR}
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
EOFecho prints a path ending in site-packages/opentelemetry/instrumentation/auto_instrumentation. With PYTHONPATH pointing there, tracing starts in any Python program started from that virtual environment: gunicorn, uvicorn, python app.py, or Celery. You don't need to change the start command. If the service already sets PYTHONPATH, join both paths with : in this file.
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
EOFIf the application isn't a systemd service, export the same lines (each prefixed with export ) in the script that starts it. As an alternative to PYTHONPATH, you can prefix the start command with <VENV_DIR>/bin/opentelemetry-instrument, for example opentelemetry-instrument gunicorn app:app.
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 '^(PYTHONPATH|OTEL_SERVICE_NAME)='
curl -s <APP_URL> > /dev/nullExpected: the service is active (running), and the last-but-one command prints your PYTHONPATH and OTEL_SERVICE_NAME.
uWSGI only: add lazy-apps = true to the uWSGI configuration. Without it, workers start before tracing is ready, and no spans are sent.
Step A3. Verify traces in OpenObserve
- Send a few requests to the application, or wait for normal traffic.
- In OpenObserve, open Traces, select the
<TRACE_STREAM>stream and the Last 15 minutes time range. - Filter on
service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds. - Open a trace. It shows the incoming request (for example
GET /orders) with child spans for 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.jsonExpected: 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-contribB1.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 asciiTo 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).ContentExpected: 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 AllowB1.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 Python application
B2.1 Install the OpenTelemetry packages into the application's virtual environment. ✏️ Replace <VENV_DIR>:
$venv = '<VENV_DIR>'
& "$venv\Scripts\pip.exe" install opentelemetry-distro opentelemetry-exporter-otlp-proto-http
& "$venv\Scripts\opentelemetry-bootstrap.exe" -a installopentelemetry-bootstrap adds an instrumentation package for each supported library it finds in the environment. Run it again after you add new libraries to the application.
B2.2 Find the folder that switches tracing on:
$autoDir = & "$venv\Scripts\python.exe" -c "import os, opentelemetry.instrumentation.auto_instrumentation as m; print(os.path.dirname(m.__file__))"
$autoDirIt prints a path ending in site-packages\opentelemetry\instrumentation\auto_instrumentation.
B2.3 Add the tracing settings to the application's Windows service. ✏️ Replace <WINDOWS_SERVICE>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>. Run this in the same PowerShell window as B2.2. 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 = @(
"PYTHONPATH=$autoDir",
'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'
)
Set-ItemProperty $key -Name Environment -Type MultiString -Value ($current + $otel)
(Get-ItemProperty $key).EnvironmentWith PYTHONPATH pointing to that folder, tracing starts in any Python program the service runs from this virtual environment, such as waitress, uvicorn or python app.py, without changing its command. This works with any service wrapper (NSSM, WinSW, pywin32). If the service already sets PYTHONPATH, join both paths with ;.
gunicorn and uWSGI don't run on Windows. Use waitress, uvicorn or hypercorn there.
For a quick test from a console. ✏️ Replace the placeholders and your usual start command:
$env:PYTHONPATH = $autoDir
$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'
& "$venv\Scripts\python.exe" -m waitress --listen=127.0.0.1:8000 app:app # your usual start commandB2.4 Restart the application and send a request. ✏️ Replace <WINDOWS_SERVICE> and <APP_URL>:
Restart-Service '<WINDOWS_SERVICE>'
Invoke-WebRequest '<APP_URL>' -UseBasicParsing | Out-NullOn Windows, call other local services at 127.0.0.1 rather than localhost. With localhost, Windows tries IPv6 first, which can add about 2 seconds to each call when the service listens only on IPv4.
Step B3. Verify traces in OpenObserve
- Send a few requests to the application, or wait for normal traffic.
- In OpenObserve, open Traces, select the
<TRACE_STREAM>stream and the Last 15 minutes time range. - Filter on
service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds. - Open a trace. It shows the incoming request with child spans for 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).hitsExpected: 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, sourceotelcol-contrib. - Application log. Set
OTEL_LOG_LEVEL=debugin the application settings for a short time to see OpenTelemetry messages in the application's output.
| Symptom | Cause | Fix |
|---|---|---|
Collector log shows 401 or 403 | Wrong <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 404 | Wrong endpoint path | O2_OTLP_ENDPOINT must be <OPENOBSERVE_URL>/api/<ORG_ID>, without /v1/traces |
Collector log shows connection refused, a timeout, or a TLS error | No network route or a proxy in between | Test with curl -I <OPENOBSERVE_URL>. If you need a proxy, add HTTPS_PROXY=http://<proxy-host>:<port> next to the other O2_* values |
validate reports at least one endpoint must be specified | The O2_* values were not loaded in the shell where you ran it | Run the command exactly as in A1.5 / B1.5 |
ModuleNotFoundError: No module named 'opentelemetry' in A2.2 / B2.2 | Packages were installed into a different Python | Run A2.1 / B2.1 with the pip inside <VENV_DIR> |
| App runs, but no traces arrive | The service doesn't use <VENV_DIR>, or the settings aren't attached | RHEL: systemctl cat <APP_UNIT> must show otel.conf, and A2.4 must print PYTHONPATH. Windows: check the service's Environment (B2.3) |
| Incoming requests traced, but no database or HTTP-client spans | Bootstrap ran before those libraries were installed | Run opentelemetry-bootstrap -a install again, then restart the app |
| No spans with uWSGI | Workers fork before tracing starts | Add lazy-apps = true to the uWSGI config |
| Application logs errors exporting metrics or logs | OTEL_METRICS_EXPORTER / OTEL_LOGS_EXPORTER missing | Set both to none; this setup collects traces only |
| Calls between services show as separate traces | A proxy or API gateway removes the traceparent header | Configure it to forward the traceparent and tracestate headers |
| Too much trace volume | Every request is traced | Add 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 PYTHONPATH and OTEL_* entries from B2.3. 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.
| Component | Version |
|---|---|
| OpenTelemetry Collector Contrib | 0.166.0 |
| opentelemetry-distro / instrumentation packages | 0.66b2 |
| opentelemetry-sdk / opentelemetry-exporter-otlp-proto-http | 1.45.2 |
| Python | 3.11 (RHEL, with gunicorn 23), 3.13.12 (Windows, with waitress 3) |
| Framework | Flask 3.1 with requests 2.32 |
| OpenObserve | v1.2.0 |
For the full list of auto-instrumented libraries, see OpenTelemetry Python instrumentation.