OpenTelemetry spans for model and tool calls
5 Jul 2026 · 7 min read
How to model LLM calls, tool calls, retries, and approvals as trace spans teams can inspect.
OpenTelemetry gives agent systems a shared language for latency, errors, cost, and dependency behavior.
AstraRunner treats this as an execution-platform concern: the run needs durable state, traceable decisions, cost visibility, and enough structure for teams to review what happened after the agent finishes.
Patterns that work
- Create spans for every model request and tool invocation.
- Record model, token count, latency, and cost attributes.
- Nest retries under the step that triggered them.
- Represent approval waits as spans or state events.
Implementation checklist
- Standardize span names.
- Avoid storing raw secrets in attributes.
- Export to existing collectors.
- Sample intelligently without losing incidents.
Watch outs
- High-volume tool calls can create trace noise.
- Token and cost attributes need provider normalization.
- Approval waits distort latency unless labeled clearly.
Related reading
How this fits the Astra stack
AstraRunner owns the operational path for agent work: orchestration, scheduling, approval gates, traces, costs, and role-agent handoffs. AstraMemory owns durable context and retrieval. AstraGenie turns those capabilities into product workflows for teams that want automation without rebuilding the platform layer.