Skip to content

feat: support per-signal OTLP endpoints for frontend telemetry#2077

Draft
MikeShi42 wants to merge 3 commits intomainfrom
cursor/HDX-3972-per-signal-otlp-endpoints-ea85
Draft

feat: support per-signal OTLP endpoints for frontend telemetry#2077
MikeShi42 wants to merge 3 commits intomainfrom
cursor/HDX-3972-per-signal-otlp-endpoints-ea85

Conversation

@MikeShi42
Copy link
Copy Markdown
Contributor

@MikeShi42 MikeShi42 commented Apr 8, 2026

Summary

Adds support for per-signal OTLP endpoint environment variables, aligning with
the OpenTelemetry specification.

Backend (API server): @hyperdx/node-opentelemetry already natively reads
per-signal env vars (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT) and
routes 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-opentelemetry via
instrumentation.ts) — also works out of the box.

Frontend (browser client): The @hyperdx/browser SDK accepts a single url
parameter. 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:

NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
NEXT_PUBLIC_OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT

Changes:

  • packages/app/src/config.ts — read per-signal env vars (HDX_TRACES_URL, HDX_LOGS_URL)
  • packages/app/src/types.ts — add tracesUrl/logsUrl to NextApiConfigResponseData
  • packages/app/pages/api/config.ts — expose per-signal URLs to the browser
  • packages/app/pages/_app.tsx — use traces endpoint as base URL when set
  • packages/app/Dockerfile — forward per-signal build args as NEXT_PUBLIC_ env vars

Tests added:

  • perSignalOtlpEndpoints.test.ts — 13 tests covering config env var resolution and browser SDK URL derivation
  • backendPerSignalEndpoints.test.ts — 6 tests confirming @hyperdx/node-opentelemetry reads per-signal env vars with correct precedence

How to test locally or on Vercel

  1. Set OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces on the app server
  2. Visit /api/config and confirm tracesUrl appears in the JSON response
  3. Verify browser telemetry is sent to the configured traces endpoint

References

Linear Issue: HDX-3972

Open in Web Open in Cursor 

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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: c21e8c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Apr 9, 2026 2:03am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

E2E Test Results

All tests passed • 130 passed • 3 skipped • 1068s

Status Count
✅ Passed 130
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants