"""AdalFlow tracing processor interface module with OpenAI Agents SDK compatibility.This module defines the interface for processing traces and spans in AdalFlow,following OpenAI Agents SDK patterns for maximum compatibility.References:- OpenAI Agents SDK: https://github.com/openai/openai-agents-python/blob/main/src/agents/tracing/processor_interface.py"""importabcfromtypingimportTYPE_CHECKING,Any,UnionifTYPE_CHECKING:from.spansimportSpanfrom.tracesimportTrace
[docs]classTracingProcessor(abc.ABC):"""Interface for processing spans."""
[docs]@abc.abstractmethoddefon_trace_start(self,trace:"Trace")->None:"""Called when a trace is started. Args: trace: The trace that started. """pass
[docs]@abc.abstractmethoddefon_trace_end(self,trace:"Trace")->None:"""Called when a trace is finished. Args: trace: The trace that started. """pass
[docs]@abc.abstractmethoddefon_span_start(self,span:"Span[Any]")->None:"""Called when a span is started. Args: span: The span that started. """pass
[docs]@abc.abstractmethoddefon_span_end(self,span:"Span[Any]")->None:"""Called when a span is finished. Should not block or raise exceptions. Args: span: The span that finished. """pass
[docs]@abc.abstractmethoddefshutdown(self)->None:"""Called when the application stops."""pass
[docs]@abc.abstractmethoddefforce_flush(self)->None:"""Forces an immediate flush of all queued spans/traces."""pass
[docs]classTracingExporter(abc.ABC):"""Exports traces and spans. For example, could log them or send them to a backend."""
[docs]@abc.abstractmethoddefexport(self,items:list[Union["Trace","Span[Any]"]])->None:"""Exports a list of traces and spans. Args: items: The items to export. """pass