Skip to content

Backend OTel bootstrap hotfix — the money path was dark, and nothing said so

2026-07-16

Six of eight backends — game-server, auth-server, both banks, betting-server, observer-gateway — emitted zero telemetry in every deployed environment. Their Dash0 config was correct; they never turned the tracer on. Production runs start, which booted dist/index.js — the file that never calls initTelemetry — while the bootstrap.ts that does was only wired into dev. Every span became a NonRecordingSpan and was dropped at creation: the code ran, the instrumentation ran, nothing left the process. It failed quiet, so nobody noticed for weeks — and it defeated the plans built on top of it (the alert pack was wired to spans that never arrived; a permission refusal carried its context to a span that was thrown away).

Found by telemetry-driven smoke: a hand was played on staging and the agent read stg. No unit test, typecheck, or green CI run could have caught it — the code and the config were both correct. Only "did the span arrive in the deployed environment?" catches this class.

What shipped

  • All 8 backends now boot bootstrap-first in production. build emits both dist/bootstrap.js (a second tsup entry) and dist/index.js (the app-entrypoint.sh build-at-boot sentinel); start boots the bootstrap, which inits OTel before the dynamic import of the app.
  • hosted-agent-service was degraded, not healthy — it inited OTel inside index.ts, after ESM hoisted the app's imports above the call, so auto-instrumentation patched nothing. Now on the same bootstrap convention.
  • assertTracerRecording moved to @numero/telemetry and is called in all 8 bootstraps (was game-server-only) — a misconfigured init is now loud at boot in every service, not silent for days.
  • check-otel-bootstrap (wired into pnpm typecheck) makes the dark-service class unrepresentable: a backend whose prod entrypoint could boot without initialising OTel before the app loads fails CI. It found a real gap on day one (tournament-orchestrator's bootstrap lacked the assertion).
  • A hermetic prod-boot harness (test/otel-bootstrap/) builds each service, boots its real start entry against a local OTLP stub, and proves the prod entrypoint initialises OTel + is recording — race-free, no docker, no real config.

The convention: bootstrap-first is the prod entrypoint, not just dev — see the observability guide.