Compute agent service level indicators (SLIs) from OpenTelemetry (OTel) traces. Aggregate task metrics by task identity and session metrics by session identity.
Skill: agent-reliability, topic trace-based-slis (see the
skill index).
Sources
- OpenTelemetry GenAI semantic conventions
- OpenTelemetry GenAI agent spans
- OpenTelemetry semantic conventions for MCP
- OpenTelemetry blog: GenAI observability
- Honeycomb: LLMs demand observability-driven development
At a glance
Span conventions, attribute names, content capture, and backend choice are in Building Reliable Agents §1. This page adds what to compute from those spans and the Model Context Protocol (MCP) attributes that make tool errors countable.
| SLI | Computed from |
|---|---|
| Tool error rate | execute_tool spans with error.type set, over all execute_tool spans |
| Retries per turn | Explicit retry attempts inside one turn: another attempt at a failed operation, or a span marked as a retry |
| Turns per task | Agent turns counted by task id, including retries |
| Tokens per task | Token usage summed by task id, including failed and retried attempts |
| Cost per successful task | All task spend, including failed and retried attempts, divided by the number of successful tasks in the measurement window |
| Loop suspects | Sessions with repeated calls: the same tool name and arguments several times in a row; repetition alone does not establish retries or a loop |
| Stuck sessions | Time between turns above a threshold |
Decision guide
- Count plain repeated identical calls as repeated calls, not retries. Check expected polling before treating repeated calls as a loop.
- Give each task an explicit task id attribute. If one agent invocation span represents the whole task, its span id can serve as the task id. Associate all turns, retries, token usage, and spend with that task id.
- Use
gen_ai.conversation.idonly for session grouping. If a session holds several tasks, count each task by its task id. Do not synthesise a session key from a trace id or a content hash. - Sum spend by task id before calculating cost per successful task. Include failed tasks in total spend. If no task succeeds, report the ratio as undefined and show total spend and zero successes.
- If a tool runs over MCP, then record
mcp.method.nameon client and server spans. If the tool result reportsisError, then seterror.typetotool_erroreven though the protocol call succeeded. - If an agent call crosses an MCP boundary, then propagate trace context in
params._metaastraceparent,tracestate, andbaggage. - If infrastructure spans drown agent spans, then filter them at the collector but always keep error spans.
- If prompts or tool payloads would leave your trust boundary, then redact before export. Content capture stays opt-in.
Checklist
- Every task has a stable task id, distinct from session grouping.
- Spans carry agent, model, task, and consequence-tier attributes.
- Prompt, model, skill, and tool-schema versions are recorded on spans.
- Tool error rate is computed from
error.type, not by parsing payloads. - Turns, tokens, and spend are aggregated by task id.
- Cost per successful task includes spend from failed and retried attempts.
- Redaction runs before export.
Rules of thumb
- Measure tasks, not spans.
- The GenAI and MCP conventions have Development status. Pin the version you implement and recheck it before an upgrade.
- Reliability data must not become a data-leak path.
Claim review
- Every figure traces to a cited source or is labelled Own experience.
- Every factual claim stays within the cited evidence.
- Evidence limits and qualifiers remain explicit.
Privacy review
- No employer material.
- No customer material.
- No private-repository material.
- No trace material.
- No transcript material.