Interface TraceProcessor

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
BatchTraceProcessor, ConsoleTraceProcessor, MultiTracingProcessor, NoopTraceProcessor

public interface TraceProcessor extends AutoCloseable
Processor for trace and span lifecycle events.

Implementations can export traces to external systems (OpenAI, Jaeger, etc.), log to console, or perform custom processing.

Lifecycle: - onTraceStart: Called when trace begins - onTraceEnd: Called when trace ends - onSpanStart: Called when span begins - onSpanEnd: Called when span ends - forceFlush: Flush pending data - shutdown: Gracefully shutdown processor

Ported from TypeScript OpenAI Agents SDK Source: tracing/processor.ts

  • Method Details

    • onTraceStart

      void onTraceStart(Trace trace)
      Called when a trace starts. Processors can export the trace immediately or buffer it.
    • onTraceEnd

      void onTraceEnd(Trace trace)
      Called when a trace ends.
    • onSpanStart

      void onSpanStart(Span<?> span)
      Called when a span starts.
    • onSpanEnd

      void onSpanEnd(Span<?> span)
      Called when a span ends. Most processors export spans on end to capture complete data.
    • forceFlush

      CompletableFuture<Void> forceFlush()
      Flush all pending traces/spans. Blocks until all data is exported.
    • shutdown

      CompletableFuture<Void> shutdown(long timeoutMs)
      Shutdown the processor gracefully. Flushes pending data and releases resources.
      Parameters:
      timeoutMs - Maximum time to wait for shutdown (milliseconds)
    • shutdown

      default CompletableFuture<Void> shutdown()
      Default shutdown with 5 second timeout.
    • close

      default void close() throws Exception
      AutoCloseable implementation. Calls shutdown() and blocks.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception