OpenTelemetry tracer adapter for Jido.Observe.
This module implements Jido.Observe.Tracer and maps Jido span lifecycle
callbacks to OpenTelemetry spans.
Summary
Types
Controls whether span_start/2 mutates process-local current span context.
Context carried from span_start/2 to stop/exception callbacks.
Functions
Finalizes a failed span, records an exception event, and marks the span as error.
Starts an OpenTelemetry span from a Jido event prefix and metadata map.
Finalizes a successful span and attaches measurements as span attributes.
Runs synchronous work inside an active OpenTelemetry span.
Types
@type current_span_mode() :: :safe | :activate_unsafe
Controls whether span_start/2 mutates process-local current span context.
:safe is OTP-safe across async boundaries and does not activate the started span
as the current process span.
:activate_unsafe preserves same-process activation/restore behavior.
@type tracer_ctx() :: Jido.Otel.Tracer.Context.t()
Context carried from span_start/2 to stop/exception callbacks.
Functions
@spec span_exception(Jido.Observe.Tracer.tracer_ctx(), atom(), term(), list()) :: :ok
Finalizes a failed span, records an exception event, and marks the span as error.
Terminal callbacks are idempotent: first terminal call wins.
@spec span_start(Jido.Observe.Tracer.event_prefix(), Jido.Observe.Tracer.metadata()) :: tracer_ctx()
Starts an OpenTelemetry span from a Jido event prefix and metadata map.
The event prefix is converted to a dot-joined span name and metadata is normalized into OpenTelemetry-compatible span attributes.
See current_span_mode/0 for current-span activation behavior.
@spec span_stop(Jido.Observe.Tracer.tracer_ctx(), Jido.Observe.Tracer.measurements()) :: :ok
Finalizes a successful span and attaches measurements as span attributes.
Terminal callbacks are idempotent: first terminal call wins.
@spec with_span_scope( Jido.Observe.Tracer.event_prefix(), Jido.Observe.Tracer.metadata(), (-> result) ) :: result when result: term()
Runs synchronous work inside an active OpenTelemetry span.
This callback is used by Jido.Observe.with_span/3 when available. Unlike
async span_start/2, scoped spans intentionally activate the OTel span only
for the duration of the provided function and restore the previous current
span before returning.