Basic Manual Trace Control
Starting and Ending Traces
The most basic form of manual trace control involves starting a trace, executing your code, and then ending the trace with a specific state:Trace Names and Tags
You can provide meaningful names and tags when starting traces:Batch Processing with Selective Trace Ending
For batch processing scenarios, you can selectively end traces based on processing results:Updating Trace Metadata During Execution
You can update metadata on running traces at any point during execution using theupdate_trace_metadata
function. This is useful for adding context, tracking progress, or storing intermediate results.
Basic Metadata Updates
Semantic Convention Support
The function automatically maps user-friendly keys to semantic conventions when possible:Advanced Metadata with Custom Prefix
You can specify a custom prefix for your metadata attributes:Real-World Example: Progress Tracking
Here’s how to use metadata updates to track progress through a complex workflow:Supported Data Types
Theupdate_trace_metadata
function supports various data types:
Integration with Decorators
Manual trace control works seamlessly with AgentOps decorators:Real-World Example
Here’s a comprehensive example showing manual trace control in a customer service application:- Individual trace management for each customer request
- Integration with decorated agents and tools
- Different end states based on business logic
- Proper error handling with appropriate trace states
- Use of tags for categorization