Class BatchTraceProcessor

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

public class BatchTraceProcessor extends Object implements TraceProcessor
BatchTraceProcessor

Buffers traces and spans in memory and exports them in batches. Provides configurable batching behavior with automatic and manual flush.

Key Features: - In-memory buffering with bounded queue - Periodic batch export (every N seconds) - Threshold-based export (when queue is 80% full) - Graceful shutdown with final flush - Thread-safe operations

Thread Safety: - BlockingQueue handles concurrent enqueue from multiple threads - Synchronized exportBatch() ensures only one export runs at a time - ScheduledExecutorService provides periodic exports on single thread

Usage:

 BatchTraceProcessor processor = new BatchTraceProcessor(
     exporter,
     BatchTraceProcessor.Config.builder()
         .maxBatchSize(100)
         .scheduleDelayMs(5000)
         .build()
 );
 
Source: https://github.com/openai/openai-agents-js/blob/main/packages/agents-core/src/tracing/batcher.ts