feat(opentelemetry): expose OtlpExporter as public API by jonastemplestein · Pull Request #5855 · Effect-TS/effect
Summary
Exposes the internal OTLP exporter as OtlpExporter.make() to allow building custom multi-endpoint tracers or composing multiple exporters without copying internal code.
Motivation
When building applications that need to send traces to multiple backends (e.g., Honeycomb + Axiom + Sentry), the current options are:
- Use
NodeSdkwith multipleSpanProcessors (requires@opentelemetry/sdk-trace-base) - Copy the internal exporter code
Exposing the exporter allows Effect-native multi-endpoint tracing without any OpenTelemetry SDK dependencies:
import { OtlpExporter, OtlpResource } from "@effect/opentelemetry" const makeMultiExporter = (endpoints: Array<EndpointConfig>) => Effect.gen(function*() { const exporters = yield* Effect.forEach(endpoints, e => OtlpExporter.make({ url: e.url, headers: e.headers, label: e.name, exportInterval: "5 seconds", maxBatchSize: 100, body: (spans) => ({ resourceSpans: [{ scopeSpans: [{ spans }] }] }), shutdownTimeout: "3 seconds" }) ) return { push: (data: unknown) => exporters.forEach(e => e.push(data)) } })
Changes
- Added
src/OtlpExporter.ts- public module re-exporting the internal exporter with proper JSDoc documentation - Updated
src/index.ts- addedOtlpExporterexport - Added changeset
Test Plan
- Existing tests pass (no behavioral changes)
- Would be good to add a test for the new public API
🤖 Generated with Claude Code