Repository navigation
fix(telemetry): send browser events to the configured collector and keep logs off the anonymous one - #9317
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryThe PR separates browser and server telemetry destinations and limits what reaches the anonymous collector.
The earlier concerns about configured fallbacks, URL paths, anonymous-host detection, and browser-routing docs are addressed.
|
…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.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
…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.
|
@greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
…ocument routing per side
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
Summary
/api/telemetry) read onlyTELEMETRY_ENDPOINT. A deployment that exports to its own collector throughOTEL_EXPORTER_OTLP_ENDPOINT(with auth inOTEL_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.NEXT_TELEMETRY_DISABLED, so Docker and Helm installs, which set it by default, still forwarded browser events.traceId/spanIdand used the retiredinstrumentationLibrarySpansfield, which current collectors drop.telemetry.config.tsdescribes.Changes:
lib/monitoring/otlp.ts:resolveOtlpTarget()(OTEL_EXPORTER_OTLP_ENDPOINT→TELEMETRY_ENDPOINT→ configured fallback, plus OTLP headers),isTelemetryDisabled(), the sharednormalizeOtlpTracesUrl, and theANONYMOUS_TELEMETRY_ENDPOINTconstant.TELEMETRY_ENDPOINTor the configured anonymous collector (telemetry.config.ts), returnsforwarded: falsewithout sending when telemetry is disabled, and emits valid OTLP JSON (scopeSpans, 32-hex trace id, 16-hex span id).resolveOtlpTarget()never sendsOTEL_EXPORTER_OTLP_HEADERSto 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.tsexports logs and metrics only to a collector the operator configured; on the anonymous endpoint it exports traces only. Explicit emptymetricReaders/logRecordProcessorslists, because NodeSDK otherwise builds default OTLP exporters from env.TELEMETRY_ENDPOINT.Type of Change
Testing
End to end against a real OpenTelemetry Collector (0.114.0, debug exporter), driving the actual
POSThandler:TELEMETRY_ENDPOINTpointing at the collector and an operator collector +Authorizationheader also configured:forwarded: true, posted to/v1/tracesonTELEMETRY_ENDPOINTwith noAuthorizationheader, the operator collector never contacted; the collector decoded the span (page_view.view, valid trace/span ids).NEXT_TELEMETRY_DISABLED=1:forwarded: false, nothing sent.Plus biome,
check:utils,check:comment-hygiene; type-check and the full audit suite run in CI.Checklist
test-auditauthoring gate)