Spans
AgentOps uses spans to track different types of operations in your agent workflows.
Spans Overview
In AgentOps v0.4, the concept of “Events” has been replaced with “Spans” for all operation tracking. Spans represent different types of operations and are organized hierarchically.
A span is a unit of work or operation in your agent workflow. Spans are created using decorators and are automatically nested to create a hierarchical trace of your agent’s execution.
Span Types
AgentOps supports several types of spans, each representing a different kind of operation:
Session Spans
Session spans serve as the root for all other spans. They represent a complete execution of your agent workflow.
Agent Spans
Agent spans represent operations performed by a specific agent. They are typically children of session spans.
Operation/Task Spans
Operation spans represent specific tasks or operations performed by an agent. They are typically children of agent spans.
Workflow Spans
Workflow spans represent a sequence of operations that form a workflow. They can contain multiple operations.
LLM Spans
LLM spans are automatically created when you make calls to supported LLM providers. They represent interactions with language models.
Span Attributes
All spans share a set of common attributes:
Attribute | Description |
---|---|
span_id | A unique identifier for the span |
trace_id | The ID of the trace this span belongs to |
parent_id | The ID of the parent span |
name | The name of the span |
kind | The kind of span (session, agent, operation, etc.) |
start_time | When the span started |
end_time | When the span ended |
attributes | Custom attributes for the span |
Additionally, spans automatically capture:
- Input parameters to the decorated function
- Return values from the decorated function
- Exceptions that occur during execution
Span Hierarchy
Spans are organized hierarchically to create a trace of your agent’s execution. The typical hierarchy is:
- Session (root)
- Agent
- Operation/Task
- Nested Operations
This hierarchy allows you to visualize the flow of your agent’s execution and understand how different operations relate to each other.
Error Handling
When an exception occurs within a decorated function, it’s automatically recorded in the span. This allows you to easily identify and debug errors in your agent workflow.