dragon.ai.agent.observability.tracer.Span

class Span[source]

Bases: object

A single timed operation in the trace tree.

Attributes

span_id:

Unique identifier for this span (auto-generated uuid4).

trace_id:

Shared identifier across all spans in a pipeline run.

parent_id:

span_id of the parent span, or None for root spans. Automatically set by trace_span() via _current_span ContextVar.

name:

Human-readable label (e.g. agent name, model name, tool name).

kind:

Classification of this span (SpanKind).

start_time:

Unix timestamp when the span started.

end_time:

Unix timestamp when the span ended, or None while in-progress.

attributes:

Structured data captured during the span. Uses namespaced keys: llm.model, tool.name, hitl.approved, agent.id, etc.

error:

Exception string if the span failed, or None.

__init__(span_id: str = <factory>, trace_id: str = '', parent_id: str | None = None, name: str = '', kind: SpanKind = SpanKind.TASK, start_time: float = <factory>, end_time: float | None = None, attributes: dict[str, ~typing.Any]=<factory>, error: str | None = None) None

Methods

__init__(span_id, trace_id, parent_id, name, ...)

from_dict(d)

Reconstruct a Span from a dict (e.g. from JSON).

to_dict()

Serialise to a plain dict (JSON-safe).

Attributes

end_time

error

kind

name

parent_id

trace_id

span_id

start_time

attributes

span_id: str
trace_id: str = ''
parent_id: str | None = None
name: str = ''
kind: SpanKind = 'TASK'
start_time: float
end_time: float | None = None
attributes: dict [str , Any ]
error: str | None = None
to_dict() dict [str , Any ][source]

Serialise to a plain dict (JSON-safe).

classmethod from_dict(d: dict [str , Any ]) Span[source]

Reconstruct a Span from a dict (e.g. from JSON).

__init__(span_id: str = <factory>, trace_id: str = '', parent_id: str | None = None, name: str = '', kind: SpanKind = SpanKind.TASK, start_time: float = <factory>, end_time: float | None = None, attributes: dict[str, ~typing.Any]=<factory>, error: str | None = None) None