Problem
src/tracer.ts constructs a NodeSDK and calls sdk.start() unconditionally at import time, with OTLP_ENDPOINT defaulting to http://localhost:4318. This means every run of the service starts tracing and attempts to export spans to a local collector, even in development or CI where no collector exists, producing connection errors and overhead. There is no flag to disable it and no graceful shutdown.
What needs to be done
- Gate startup behind an explicit env flag (for example
TRACING_ENABLED), off by default, or auto-disable when OTLP_ENDPOINT is unset.
- Wrap
sdk.start() so exporter/connection errors are logged and do not crash or spam the process.
- Register a shutdown hook (
sdk.shutdown()) on SIGTERM/SIGINT so spans flush cleanly.
- Document the tracing environment variables (
OTLP_ENDPOINT, SERVICE_NAME, the new enable flag) in the README and .env.example.
Files
src/tracer.ts
.env.example, README.md
Acceptance deliverables
- Tracing is off by default and only starts when explicitly enabled or configured.
- A missing/unreachable collector does not produce repeated crashes or error spam.
- All CI checks pass; the change cannot be merged until CI is green.
Tests to pass
- Test: with tracing disabled/unconfigured, the SDK does not start.
- Test: an exporter initialization error is handled without throwing.
Problem
src/tracer.tsconstructs aNodeSDKand callssdk.start()unconditionally at import time, withOTLP_ENDPOINTdefaulting tohttp://localhost:4318. This means every run of the service starts tracing and attempts to export spans to a local collector, even in development or CI where no collector exists, producing connection errors and overhead. There is no flag to disable it and no graceful shutdown.What needs to be done
TRACING_ENABLED), off by default, or auto-disable whenOTLP_ENDPOINTis unset.sdk.start()so exporter/connection errors are logged and do not crash or spam the process.sdk.shutdown()) onSIGTERM/SIGINTso spans flush cleanly.OTLP_ENDPOINT,SERVICE_NAME, the new enable flag) in the README and.env.example.Files
src/tracer.ts.env.example,README.mdAcceptance deliverables
Tests to pass