feat(tracing): send OTLP traces to the target environment's collector#650
Conversation
The SDK tracer and logger hard-coded the prod collector (otlp-sdk.rapidata.ai) and RapidataClient disabled OTLP entirely for any non-prod environment, so traces from the test environment were silently dropped. Derive the collector host from the client's environment (otlp-sdk.<environment>), matching how the api./auth. endpoints are built, and enable OTLP for environments that actually have a deployed collector (prod rapidata.ai + test rabbitdata.ch). Local dev (rapidata.dev) has no collector, so it stays disabled to avoid noisy failed exports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: lino <lino@rapidata.ai>
ReviewNice, focused fix — deriving the collector host from Bug: OTLP endpoint is locked to whichever environment first initializes it, for the life of the process
if self._otlp_initialized:
return
...
exporter = OTLPSpanExporter(endpoint=f"https://otlp-sdk.{self._environment}/v1/traces", ...)
...
self._otlp_initialized = True
Concretely: if a process creates Related:
|
What
SDK traces (and logs) only ever reached the prod collector. Two things blocked non-prod:
RapidataClient.__init__disabled OTLP entirely wheneverenvironment != "rapidata.ai".https://otlp-sdk.rapidata.ai/v1/{traces,logs}.This derives the collector host from the client's
environment—otlp-sdk.<environment>— the same wayapi.<env>/auth.<env>are built, and enables OTLP for the environments that actually have a deployed collector.Environments
environmentstringrapidata.aiotlp-sdk.rapidata.airabbitdata.chotlp-sdk.rabbitdata.chrapidata.devThe test collector already exists —
infrastructure'sobservability/overlays/test/httproute-otlp-sdk.yamlroutesotlp-sdk.rabbitdata.ch, andPOST /v1/tracesreturns 200 (verified against both prod and test). Local dev is intentionally excluded (per request): its local collector is exposed under a different host (otlp.rapidata.dev) and uses a self-signed cert, so enabling it there would only produce failed exports. Unknown environments stay off for the same reason.How
LoggingConfiggains anenvironmentfield (the existing config-update channel the tracer/logger already listen on).RapidataTracer/RapidataLoggerbuild their endpoint from that value.RapidataClientsetsenvironmenton the config and enables OTLP only for_OTLP_COLLECTOR_ENVIRONMENTS(prod + test).Checks
pyright src/rapidata/rapidata_client→ 0 errors.🔗 Session: https://session-7f001dc5.poseidon.rapidata.internal/