Class MultiTracingProcessor

java.lang.Object
ai.acolite.agentsdk.core.tracing.MultiTracingProcessor
All Implemented Interfaces:
TraceProcessor, AutoCloseable

public class MultiTracingProcessor extends Object implements TraceProcessor
MultiTracingProcessor

Composite processor that delegates trace/span events to multiple processors. Allows combining multiple tracing backends (console, cloud, custom).

Thread-safe: Uses CopyOnWriteArrayList for processor list.

Example:

 MultiTracingProcessor multi = new MultiTracingProcessor();
 multi.addTraceProcessor(new ConsoleTraceProcessor());
 multi.addTraceProcessor(new BatchTraceProcessor(...));
 
Ported from TypeScript OpenAI Agents SDK Source: https://github.com/openai/openai-agents-js/blob/main/packages/agents-core/src/tracing/processor.ts
  • Constructor Details

    • MultiTracingProcessor

      public MultiTracingProcessor()
  • Method Details

    • addTraceProcessor

      public void addTraceProcessor(TraceProcessor processor)
      Add a processor to the list. Each processor will receive all trace/span events.
    • setProcessors

      public void setProcessors(List<TraceProcessor> newProcessors)
      Replace all processors with a new list.
    • getProcessors

      public List<TraceProcessor> getProcessors()
      Get all registered processors (immutable copy).
    • clear

      public void clear()
      Remove all processors.
    • onTraceStart

      public void onTraceStart(Trace trace)
      Description copied from interface: TraceProcessor
      Called when a trace starts. Processors can export the trace immediately or buffer it.
      Specified by:
      onTraceStart in interface TraceProcessor
    • onTraceEnd

      public void onTraceEnd(Trace trace)
      Description copied from interface: TraceProcessor
      Called when a trace ends.
      Specified by:
      onTraceEnd in interface TraceProcessor
    • onSpanStart

      public void onSpanStart(Span<?> span)
      Description copied from interface: TraceProcessor
      Called when a span starts.
      Specified by:
      onSpanStart in interface TraceProcessor
    • onSpanEnd

      public void onSpanEnd(Span<?> span)
      Description copied from interface: TraceProcessor
      Called when a span ends. Most processors export spans on end to capture complete data.
      Specified by:
      onSpanEnd in interface TraceProcessor
    • shutdown

      public CompletableFuture<Void> shutdown(long timeoutMs)
      Description copied from interface: TraceProcessor
      Shutdown the processor gracefully. Flushes pending data and releases resources.
      Specified by:
      shutdown in interface TraceProcessor
      Parameters:
      timeoutMs - Maximum time to wait for shutdown (milliseconds)
    • forceFlush

      public CompletableFuture<Void> forceFlush()
      Description copied from interface: TraceProcessor
      Flush all pending traces/spans. Blocks until all data is exported.
      Specified by:
      forceFlush in interface TraceProcessor