effect icon indicating copy to clipboard operation
effect copied to clipboard

feat(opentelemetry): expose OtlpExporter as public API

Open jonastemplestein opened this issue 4 weeks ago • 1 comments

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

  • [x] Existing tests pass (no behavioral changes)
  • [ ] Would be good to add a test for the new public API

🤖 Generated with Claude Code

jonastemplestein avatar Dec 03 '25 12:12 jonastemplestein

🦋 Changeset detected

Latest commit: 41e5623a893fb287938bfd54eb78d69e1131879b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/opentelemetry Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 03 '25 12:12 changeset-bot[bot]