-
-
Notifications
You must be signed in to change notification settings - Fork 476
Open
Description
Hi! We're using Effect's OTLP tracer (@effect/opentelemetry/Otlp) but also need an @opentelemetry/api Tracer for libraries expecting the OTel API. We're currently bridging the Effect tracer to an OTel API tracer with a custom adapter and using it as a workaround.
Question: Is there an official/idiomatic way to get interop between Effect's tracer (Otlp/OtelTracer) and the @opentelemetry/api tracer? Any recommended patterns or utilities to avoid maintaining a custom adapter?
Workaround (abridged):
const makeOtelEffectBridgeLayer = ({ baseUrl, serviceName, tracerExportInterval = 500 }) => {
const otlpLayer = baseUrl
? Otlp.layer({ baseUrl, resource: { serviceName }, tracerExportInterval })
: Layer.empty
const otelAdapterLayer = Layer.effect(
OtelTracer.OtelTracer,
Effect.gen(function* () {
const otlpTracer = yield* Effect.tracer
return makeOtelTracerAdapter(otlpTracer)
}),
).pipe(Layer.provide(otlpLayer))
const otelEffectTracerLayer = Layer.unwrapEffect(Effect.map(OtelTracer.make, Layer.setTracer)).pipe(
Layer.provide(otelAdapterLayer),
)
return otelEffectTracerLayer.pipe(Layer.provideMerge(otelAdapterLayer))
}makeOtelTracerAdapter maps OTel API spans to Effect spans (parent context, links, attributes, timestamps). We're happy to share full code if useful.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels