Advanced level · Module 9: Agent Evaluation and Performance Monitoring · Lesson 2 of 3
Tracing, Cost and Latency
Learners trace every agent step as spans with timing, tokens and outcomes, and use the traces to find bottlenecks and enforce budgets.
In this lesson you will
- Trace multi-agent runs with spans
- Profile and reduce cost and latency
Key concepts
trace and spanparent-child spanstoken and cost per spanlatency percentilesbudget enforcement
The lesson
A trace records one run; spans record each step (orchestrator plan, each worker, each tool call) with start and end time, tokens, cost estimate and outcome, linked as parent and child. Simple JSON-lines logs with trace and span IDs are enough to start.
Profiles show where time and money go: often one agent or one large context dominates. Report median and 95th-percentile latency, because averages hide slow cases.
Budgets per run (tokens, calls, time) are enforced in the orchestrator and visible in traces.
Step by step
- Add trace and span IDs to all logs.
- Record tokens, cost estimate and time per span.
- Produce a profile of 50 runs with p50 and p95 latency.
- Optimise the most expensive step and re-measure.
Practice activity
Produce a cost and latency profile of the capstone with one optimisation.
Expected result: A clear profile and a measured improvement.
Check your understanding
-
What is a span?
Show answer
A record of one step in a trace, with timing and outcome.
-
Why report 95th-percentile latency?
Show answer
Averages hide the slow cases users experience.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.