Skip to content

fix(telemetry): send browser events to the configured collector and keep logs off the anonymous one - #9317

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/telemetry-endpoint
Oct 22, 2026
Merged

waleedlatif1 merged 4 commits into
stagingfrom
fix/telemetry-endpoint

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • The browser telemetry route (/api/telemetry) read only TELEMETRY_ENDPOINT. A deployment that exports to its own collector through OTEL_EXPORTER_OTLP_ENDPOINT (with auth in OTEL_EXPORTER_OTLP_HEADERS) still posted browser events to the anonymous default, without auth, and each call waited out a 5s timeout when that host was unreachable.
  • The route ignored NEXT_TELEMETRY_DISABLED, so Docker and Helm installs, which set it by default, still forwarded browser events.
  • Its spans had no traceId/spanId and used the retired instrumentationLibrarySpans field, which current collectors drop.
  • Server-side, an install on the anonymous default also exported all server logs and metrics there, beyond the traces the privacy notice in telemetry.config.ts describes.

Changes:

  • lib/monitoring/otlp.ts: resolveOtlpTarget() (OTEL_EXPORTER_OTLP_ENDPOINT → TELEMETRY_ENDPOINT → configured fallback, plus OTLP headers), isTelemetryDisabled(), the shared normalizeOtlpTracesUrl, and the ANONYMOUS_TELEMETRY_ENDPOINT constant.
  • Browser events are unauthenticated input, so they never travel with the operator's collector credentials: the route sends them to TELEMETRY_ENDPOINT or the configured anonymous collector (telemetry.config.ts), returns forwarded: false without sending when telemetry is disabled, and emits valid OTLP JSON (scopeSpans, 32-hex trace id, 16-hex span id).
  • resolveOtlpTarget() never sends OTEL_EXPORTER_OTLP_HEADERS to the anonymous collector, recognizes it by host however the URL is written, and the traces URL is built on the parsed path (query strings kept, trailing slash accepted).
  • instrumentation-node.ts exports logs and metrics only to a collector the operator configured; on the anonymous endpoint it exports traces only. Explicit empty metricReaders/logRecordProcessors lists, because NodeSDK otherwise builds default OTLP exporters from env.
  • Self-hosting docs updated for TELEMETRY_ENDPOINT.

Type of Change

  • Bug fix

Testing

End to end against a real OpenTelemetry Collector (0.114.0, debug exporter), driving the actual POST handler:

  • With TELEMETRY_ENDPOINT pointing at the collector and an operator collector + Authorization header also configured: forwarded: true, posted to /v1/traces on TELEMETRY_ENDPOINT with no Authorization header, the operator collector never contacted; the collector decoded the span (page_view.view, valid trace/span ids).
  • With NEXT_TELEMETRY_DISABLED=1: forwarded: false, nothing sent.
  • The earlier version of the script against current staging failed every enabled-path check (it sent nowhere configured).

Plus biome, check:utils, check:comment-hygiene; type-check and the full audit suite run in CI.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…eep logs off the anonymous one

The browser telemetry route read only TELEMETRY_ENDPOINT, so a deployment exporting to its own
collector through OTEL_EXPORTER_OTLP_ENDPOINT still posted browser events to the anonymous
default, ignored NEXT_TELEMETRY_DISABLED, and built spans without trace or span ids under the
retired instrumentationLibrarySpans field. It now resolves the endpoint and headers exactly like
the server export, honors the disable flag, and emits valid OTLP. Server logs and metrics are no
longer exported to the anonymous collector, which receives traces only.
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Oct 22, 2026 9:53pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/monitoring/otlp.ts Outdated
Comment thread apps/sim/app/api/telemetry/route.ts Outdated
Comment thread apps/sim/lib/monitoring/otlp.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

The PR separates browser and server telemetry destinations and limits what reaches the anonymous collector.

  • Browser telemetry reaches its configured collector as a readable span.
  • The server sends logs and metrics only to a collector the operator chose.

The earlier concerns about configured fallbacks, URL paths, anonymous-host detection, and browser-routing docs are addressed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Browser[Browser event] --> Disabled{Telemetry disabled?}
  Disabled -->|Yes| Skip[Do not forward]
  Disabled -->|No| Relay[TELEMETRY_ENDPOINT or configured fallback]
  Relay --> BrowserTrace[Send trace without operator headers]
  Server[Server telemetry] --> Target[Resolve operator endpoint or fallback]
  Target --> Anonymous{Anonymous collector?}
  Anonymous -->|Yes| Traces[Export traces only without operator headers]
  Anonymous -->|No| AllSignals[Export traces, logs, and metrics with configured headers]
Loading

Reviews (4) · Last reviewed commit: "fix(telemetry): post browser events to T..." · Reviewed by Greptile

Comment thread apps/sim/app/api/telemetry/route.ts Outdated
Comment thread apps/sim/app/api/telemetry/route.ts Outdated
Comment thread apps/sim/lib/monitoring/otlp.ts Outdated
…point, match it by host

OTEL_EXPORTER_OTLP_HEADERS belong to the operator's collector, so they are dropped when the
endpoint resolves to the anonymous one; that check now compares hosts, so any spelling of the
anonymous URL gets traces only. The browser relay falls back to telemetry.config.ts like the
server export, and the traces URL is built on the parsed path, keeping query strings and
accepting a trailing slash.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/telemetry/route.ts Outdated
…r events

/api/telemetry relays unauthenticated input, so sending it with OTEL_EXPORTER_OTLP_HEADERS let
anyone write spans into the operator's authenticated collector. Browser events now go only to
TELEMETRY_ENDPOINT or the configured anonymous collector, without credentials; the server's own
export keeps using the operator's collector.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/telemetry/route.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

This branch was successfully deployed

1 active deployment
Preview — 5610ee07 Deployed Oct 22, 2026 by vercel[bot]
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.

1 participant