Class Trace

java.lang.Object
ai.acolite.agentsdk.core.tracing.Trace
Direct Known Subclasses:
NoopTrace

public class Trace extends Object
Represents a single end-to-end workflow trace.

A trace captures the execution of an entire workflow, containing multiple spans for individual operations (agents, generations, tools, etc.).

Lifecycle: 1. Create trace with builder 2. Call start() to begin 3. Execute workflow (creates spans) 4. Call end() to complete

Thread-safe: Yes

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

  • Constructor Details

    • Trace

      public Trace()
  • Method Details

    • start

      public void start()
      Start the trace. Calls processor.onTraceStart(). Idempotent - multiple calls are safe.
    • end

      public void end()
      End the trace. Calls processor.onTraceEnd(). Idempotent - multiple calls are safe.
    • clone

      public Trace clone()
      Clone this trace with same properties. Useful for creating related traces with shared configuration.
      Overrides:
      clone in class Object
    • withProcessor

      public Trace withProcessor(TraceProcessor processor)
      Clone this trace with a different processor.
      Parameters:
      processor - Processor for lifecycle events
      Returns:
      New trace instance with updated processor
    • toJson

      public Map<String,Object> toJson(boolean includeTracingApiKey)
      Convert to JSON for export.
      Parameters:
      includeTracingApiKey - Whether to include API key in output
      Returns:
      JSON representation
    • toJson

      public Map<String,Object> toJson()
      Convert to JSON (excludes API key by default for security)