spans

AdalFlow spans module with OpenAI Agents SDK compatible interface.

This module provides span implementations for AdalFlow tracing that follow the OpenAI Agents SDK patterns for maximum compatibility with existing observability backends.

References: - OpenAI Agents SDK: https://github.com/openai/openai-agents-python/blob/main/src/agents/tracing/spans.py

class SpanError[source]

Bases: TypedDict

message: str
data: Dict[str, Any] | None
class Span[source]

Bases: ABC, Generic[TSpanData]

abstract property trace_id: str
abstract property span_id: str
abstract property span_data: TSpanData
abstract start(mark_as_current: bool = False)[source]

Start the span.

Parameters:

mark_as_current – If true, the span will be marked as the current span.

abstract finish(reset_current: bool = False) None[source]

Finish the span.

Parameters:

reset_current – If true, the span will be reset as the current span.

abstract property parent_id: str | None
abstract set_error(error: SpanError) None[source]
abstract property error: SpanError | None
abstract export() Dict[str, Any] | None[source]
abstract property started_at: str | None
abstract property ended_at: str | None
class NoOpSpan(span_data: TSpanData)[source]

Bases: Span[TSpanData]

property trace_id: str
property span_id: str
property span_data: TSpanData
property parent_id: str | None
start(mark_as_current: bool = False)[source]

Start the span.

Parameters:

mark_as_current – If true, the span will be marked as the current span.

finish(reset_current: bool = False) None[source]

Finish the span.

Parameters:

reset_current – If true, the span will be reset as the current span.

set_error(error: SpanError) None[source]
property error: SpanError | None
export() Dict[str, Any] | None[source]
property started_at: str | None
property ended_at: str | None
class SpanImpl(trace_id: str, span_id: str | None, parent_id: str | None, processor: TracingProcessor, span_data: TSpanData)[source]

Bases: Span[TSpanData]

property trace_id: str
property span_id: str
property span_data: TSpanData
property parent_id: str | None
start(mark_as_current: bool = False)[source]

Start the span.

Parameters:

mark_as_current – If true, the span will be marked as the current span.

finish(reset_current: bool = False) None[source]

Finish the span.

Parameters:

reset_current – If true, the span will be reset as the current span.

set_error(error: SpanError) None[source]
property error: SpanError | None
property started_at: str | None
property ended_at: str | None
export() Dict[str, Any] | None[source]