Skip to content

Support OTLP span and log export in browser environments #22118

Description

@Prithvirajkumar

The otlpIntegration in @sentry/node-core/light forwards spans to Sentry's OTLP endpoint or a custom collector via OTLPTraceExporter + BatchSpanProcessor. No equivalent exists for browser environments, and log forwarding via OTLP is absent everywhere in the SDK.

Current behavior:

  • otlpIntegration is Node-only (packages/node-core/src/light/integrations/otlpIntegration.ts); it supports both Sentry's OTLP endpoint and a custom collectorUrl
  • Logs always use Sentry's envelope format (application/vnd.sentry.items.log+json) via createLogEnvelope — no OTLP log path exists in any environment

Gap:
Teams running their own OpenTelemetry collector pipeline can't route spans or logs from browser apps to it via Sentry SDKs. The Node light SDK proves the pattern is viable; the browser gap is primarily about bundle-size gating and ensuring the fetch-based OTLP transport works correctly.

Options:

  1. Extend otlpIntegration to browserOTLPTraceExporter supports fetch/XMLHttpRequest. The main work is tree-shaking the OTel exporter behind an explicit import path (similar to the existing @sentry/node-core/light/otlp entrypoint) to avoid bloating the default bundle.

  2. Add OTLP log forwarding — Sentry's SerializedLog shape (severity_number, body, trace_id, OTel-style attributes) maps closely to an OTLP LogRecord. A log exporter option alongside enableLogs: true would let users forward structured logs to any OTLP collector endpoint.

These two options are independent and can be scoped separately.

--

View Junior Session in Sentry

Metadata

Metadata

Assignees

Fields

No fields configured for issues without a type.

Projects

Status
Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions