Field guide

Observability: SLIs from traces

Compute agent service level indicators (SLIs) from OpenTelemetry (OTel) traces. Aggregate task metrics by task identity and session metrics by session identity.

agentic-sre

All field guidesView the source on GitHub

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

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.

SLIComputed from
Tool error rateexecute_tool spans with error.type set, over all execute_tool spans
Retries per turnExplicit retry attempts inside one turn: another attempt at a failed operation, or a span marked as a retry
Turns per taskAgent turns counted by task id, including retries
Tokens per taskToken usage summed by task id, including failed and retried attempts
Cost per successful taskAll task spend, including failed and retried attempts, divided by the number of successful tasks in the measurement window
Loop suspectsSessions with repeated calls: the same tool name and arguments several times in a row; repetition alone does not establish retries or a loop
Stuck sessionsTime 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.id only 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.name on client and server spans. If the tool result reports isError, then set error.type to tool_error even though the protocol call succeeded.
  • If an agent call crosses an MCP boundary, then propagate trace context in params._meta as traceparent, tracestate, and baggage.
  • 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.