Skip to content

fix(observability): use ENABLE_OBSERVABILITY as OTel SDK gate

Jérôme Revillard requested to merge worktree-fix-otel-default-endpoint into main

Problem

When the observability stack is disabled, the OTel Collector container is not deployed, but OTEL_EXPORTER_OTLP_ENDPOINT always defaults to http://otel-collector:4318 in docker-compose. This causes Python OPEA services to spam DNS resolution errors every 15 seconds.

Root Cause

Python tracing.py has an early-return guard (if not endpoint_base: return) that should skip SDK init when no collector is deployed. But the docker-compose default means the env var is always set — the guard never triggers.

Fix

Use ENABLE_OBSERVABILITY as the primary gate for OTel SDK initialization:

  1. docker-compose.yaml: Added ENABLE_OBSERVABILITY to all 5 application services (backend, chatqna, retriever, reranker, dataprep)
  2. Python tracing.py: New guard when ENABLE_OBSERVABILITY != 1 — SDK no-op
  3. Node.js tracing.js: Same gate

The OTEL_EXPORTER_OTLP_ENDPOINT check is kept as defense-in-depth.

User Impact

None — preserves the existing single-flag contract: ENABLE_OBSERVABILITY=1 enables everything.

Tests

  • Python: 51 passed (2 new tests for ENABLE_OBSERVABILITY gate)
  • Node.js: 66 passed (1 new test for ENABLE_OBSERVABILITY gate)

Merge request reports

Loading