Skip to content

otlp

etrack.providers.drivers.sink.otlp

providers/drivers/sink/otlp: OtlpDriver — frames as OpenTelemetry spans and logs, exported over OTLP/HTTP.

A START opens a span, its END or ERROR closes it at the frame's own time; an INSTANT is a span born closed. Ids are derived, never minted: the trace id is the run id and a span id the low 64 bits of the frame's id, so the same run and the same span carry the same names in every backend and in the live stream. Each span speaks three dialects at once — OpenTelemetry GenAI (gen_ai.*), OpenInference (openinference.span.kind, input.value, llm.*) and Langfuse's keys (langfuse.observation.type, langfuse.session.id) — each backend reads what it knows. Every collector in targets receives everything; none set, spans are still minted and dropped. With logs, each frame is also a log record on its span; processor hands the host a structlog processor that does the same for its own logs. The driver owns a private TracerProvider and LoggerProvider, never the process-global ones.

OtlpDriver

OtlpDriver(
    span_exporters: Sequence[SpanExporter] = (),
    log_exporters: Sequence[LogRecordExporter] = (),
    **given: Unpack[OtlpConfig],
)

Spans (and, with logs, log records) from frames, on private providers, exported to every target.

Keyword arguments as OtlpConfig names them; what is not given, ETRACK_OTLP_* fills (infra/defaults). Exporters handed in receive everything beside the targets' (tests, a host's own).

flush async

flush() -> bool

Export every buffered span and record now.

health async

health() -> bool

Open, and every batch flushed within the export timeout.

processor

processor() -> Any

A structlog processor for the host's own chain: every host log line also leaves as an OTel log record.

send async

send(view: EventView) -> None

Open, close or stamp the frame's span; with logs on, the frame is also a log record on it.

OtlpView

Bases: EventView

What a span needs of a frame: its place in the tree, its time, what it carried and what it cost.

RunIds

RunIds()

Bases: IdGenerator

The SDK asks for ids when a span starts: the ones pinned just before, random when none is pinned.