feat: support per-signal OTLP endpoints for frontend telemetry#2077
Draft
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.
|
Contributor
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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