Tracing
Bedrock provides full observability into agent execution through traces and spans. Every agent run creates a detailed record of what happened.Traces and Spans
- Trace: A complete record of an agent run
- Span: A single operation within a trace (LLM call, tool execution, etc.)
- run_agent
- turn_0 —
openai_api_call(LLM),list_tasks(tool),assistant_message(text) - turn_1 —
anthropic_api_call(LLM),create_task(tool),sleep(tool) - …additional turns
- turn_0 —
Span Types
Listing Traces
Get traces for an agent:Query Parameters
Getting a Trace with Spans
Span Details
Each span contains:LLM Cost Tracking
LLM spans include cost metadata:Creating Custom Traces
You can create traces programmatically for custom operations:Usage Records
When a trace ends, Bedrock automatically creates anAgentUsage record that aggregates all LLM costs from that trace. Query these via the agent usage endpoint:
Flagging Spans for Review
Mark spans that need attention (e.g., incorrect agent responses):Evals (Flagged Span Corrections)
Flagged spans are stored as eval test cases that you can browse and curate via/api/tracing/evals/:
For running full scenario-based evaluations, see Evaluations.
Debugging with Traces
Common debugging patterns:Find Failed Runs
error field.
Analyze Tool Usage
Filter spans by type to see which tools were called:Check Token Usage
LLM spans contain detailed token counts in metadata for cost analysis.Best Practices
Review Failed Traces
Check the
error field to find and fix issues.Monitor Costs
Use LLM span metadata to track spending.
Flag Bad Outputs
Use the flag endpoint to mark incorrect responses.
Trace Custom Ops
Create traces for operations outside agent runs.