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:

  1. Use NodeSdk with multiple SpanProcessors (requires @opentelemetry/sdk-trace-base)
  2. 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 - added OtlpExporter export
  • 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