naqsha.tracing¶
Hierarchical QAOA Trace span helpers
naqsha.tracing ¶
Trace store interfaces and implementations.
Span
dataclass
¶
Mutable span tracking execution metrics.
A Span represents a unit of work in the execution tree. It accumulates metrics like token counts and latency as the work progresses.
Source code in src/naqsha/tracing/span.py
metadata
class-attribute
instance-attribute
¶
add_tokens ¶
set_model_latency ¶
set_tool_exec_time ¶
to_dict ¶
Serialize span to dictionary for trace events.
Source code in src/naqsha/tracing/span.py
SpanContext
dataclass
¶
Immutable context carrying trace and span identifiers.
SpanContext is propagated through the execution tree and attached to every trace event, enabling hierarchical trace reconstruction.
Source code in src/naqsha/tracing/span.py
child_span ¶
Create a child span context with this span as parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str | None
|
Agent ID for the child span. If None, inherits from parent. |
None
|
Returns:
| Type | Description |
|---|---|
SpanContext
|
New SpanContext with this span as parent. |
Source code in src/naqsha/tracing/span.py
create_root_span ¶
Create a root span for a new trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_id
|
str
|
Unique identifier for the trace. |
required |
agent_id
|
str
|
Identifier for the agent starting the trace. |
required |
Returns:
| Type | Description |
|---|---|
Span
|
New Span with no parent. |