Package ai.acolite.agentsdk.core.tracing
Interface TraceProcessor
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BatchTraceProcessor,ConsoleTraceProcessor,MultiTracingProcessor,NoopTraceProcessor
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 Summary
Modifier and TypeMethodDescriptiondefault voidclose()AutoCloseable implementation.Flush all pending traces/spans.voidCalled when a span ends.voidonSpanStart(Span<?> span) Called when a span starts.voidonTraceEnd(Trace trace) Called when a trace ends.voidonTraceStart(Trace trace) Called when a trace starts.default CompletableFuture<Void> shutdown()Default shutdown with 5 second timeout.shutdown(long timeoutMs) Shutdown the processor gracefully.
-
Method Details
-
onTraceStart
Called when a trace starts. Processors can export the trace immediately or buffer it. -
onTraceEnd
Called when a trace ends. -
onSpanStart
Called when a span starts. -
onSpanEnd
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
Shutdown the processor gracefully. Flushes pending data and releases resources.- Parameters:
timeoutMs- Maximum time to wait for shutdown (milliseconds)
-
shutdown
Default shutdown with 5 second timeout. -
close
AutoCloseable implementation. Calls shutdown() and blocks.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-