Package ai.acolite.agentsdk.core.tracing
Class Span<TData extends SpanData>
java.lang.Object
ai.acolite.agentsdk.core.tracing.Span<TData>
- Direct Known Subclasses:
NoopSpan
Represents a timed operation within a trace.
Spans capture individual operations (agent execution, LLM generation, tool calls, etc.) with start/end timestamps, parent relationships, and operation-specific data.
Lifecycle: 1. Create span with builder 2. Call start() to begin timing 3. Execute operation 4. Call end() to finish (or setError() if failed)
Thread-safe: Yes
Ported from TypeScript OpenAI Agents SDK Source: tracing/spans.ts
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Clone this span with same properties.voidend()End the span.voidSet error information.voidConvenience method to set error from Throwablevoidstart()Start the span.toJson()Convert to JSON for export.withTracingContext(String traceId, String parentId, String tracingApiKey, TraceProcessor processor) Clone this span with updated tracing context.
-
Constructor Details
-
Span
public Span()
-
-
Method Details
-
start
public void start()Start the span. Calls processor.onSpanStart(). Idempotent - multiple calls are safe. -
end
public void end()End the span. Calls processor.onSpanEnd(). Idempotent - multiple calls are safe. -
setError
Set error information. Call this before end() when operation fails. -
setError
Convenience method to set error from Throwable -
clone
Clone this span with same properties. -
withTracingContext
public Span<TData> withTracingContext(String traceId, String parentId, String tracingApiKey, TraceProcessor processor) Clone this span with updated tracing context.- Parameters:
traceId- Parent trace identifierparentId- Parent span identifiertracingApiKey- Optional API key for trace exportprocessor- Processor for lifecycle events- Returns:
- New span instance with updated tracing context
-
toJson
Convert to JSON for export.
-