feat: support per-signal OTLP endpoints for frontend telemetry#2077
feat: support per-signal OTLP endpoints for frontend telemetry#2077
Conversation
Add support for per-signal OTLP endpoint env vars following the OpenTelemetry specification: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT OTEL_EXPORTER_OTLP_LOGS_ENDPOINT NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT NEXT_PUBLIC_OTEL_EXPORTER_OTLP_LOGS_ENDPOINT Backend (@hyperdx/node-opentelemetry) already natively supports these env vars. This change adds support in the frontend app: - config.ts: read per-signal env vars (HDX_TRACES_URL, HDX_LOGS_URL) - /api/config: expose tracesUrl and logsUrl to the browser client - _app.tsx: use traces endpoint as base URL when configured - Dockerfile: forward per-signal build args as NEXT_PUBLIC_ env vars - types.ts: add tracesUrl/logsUrl to NextApiConfigResponseData Resolves HDX-3972 Co-authored-by: Mike Shi <mike@hyperdx.io>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
E2E Test Results✅ All tests passed • 130 passed • 3 skipped • 1068s
Tests ran across 4 shards in parallel. |
Verify:
- Frontend config.ts env var resolution and fallback behavior
- Browser SDK URL derivation logic (tracesUrl → base URL stripping)
- Backend @hyperdx/node-opentelemetry per-signal endpoint support
(confirms SDK reads OTEL_EXPORTER_OTLP_{TRACES,LOGS,METRICS}_ENDPOINT
with proper precedence over OTEL_EXPORTER_OTLP_ENDPOINT)
Co-authored-by: Mike Shi <mike@hyperdx.io>
The @typescript-eslint/no-require-imports rule forbids require() calls. Switch to async import() which also works with jest.resetModules() for env-var-dependent module re-evaluation. Co-authored-by: Mike Shi <mike@hyperdx.io>
|
@MikeShi42 I didn't realize you were on it already. wondering if I should close my PR: #2098 |
Summary
Adds support for per-signal OTLP endpoint environment variables, aligning with
the OpenTelemetry specification.
Backend (API server):
@hyperdx/node-opentelemetryalready natively readsper-signal env vars (
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_LOGS_ENDPOINT,OTEL_EXPORTER_OTLP_METRICS_ENDPOINT) androutes each signal to its configured endpoint. No changes needed — confirmed
with unit tests against the installed SDK.
Frontend (Next.js server): Same SDK (
@hyperdx/node-opentelemetryviainstrumentation.ts) — also works out of the box.Frontend (browser client): The
@hyperdx/browserSDK accepts a singleurlparameter. This PR reads the per-signal env vars and derives the browser SDK's
base URL from the traces endpoint when configured. The supported env vars are:
Changes:
packages/app/src/config.ts— read per-signal env vars (HDX_TRACES_URL,HDX_LOGS_URL)packages/app/src/types.ts— addtracesUrl/logsUrltoNextApiConfigResponseDatapackages/app/pages/api/config.ts— expose per-signal URLs to the browserpackages/app/pages/_app.tsx— use traces endpoint as base URL when setpackages/app/Dockerfile— forward per-signal build args asNEXT_PUBLIC_env varsTests added:
perSignalOtlpEndpoints.test.ts— 13 tests covering config env var resolution and browser SDK URL derivationbackendPerSignalEndpoints.test.ts— 6 tests confirming@hyperdx/node-opentelemetryreads per-signal env vars with correct precedenceHow to test locally or on Vercel
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traceson the app server/api/configand confirmtracesUrlappears in the JSON responseReferences
Linear Issue: HDX-3972