---
title: How do you export AI agent traces with OpenTelemetry?
url: https://opencontroller.lyzr.com/blog/export-ai-agent-traces-with-opentelemetry
published: 2026-11-11
updated: 2026-11-11
author: Lyzr
---

# How do you export AI agent traces with OpenTelemetry?

**Instrument agents so each run produces OpenTelemetry spans that follow the GenAI semantic conventions — an `invoke_agent` span for the agent run, child spans for each model call and `execute_tool` spans for each tool call — and export them over OTLP to the collector your infrastructure already uses. Treat the attribute names as unstable: as of mid-2026 every `gen_ai.*` convention is still at Development status, so pin your instrumentation version.**

Teams that already export infrastructure telemetry through OpenTelemetry want agent activity in the same pipeline, not in a separate vendor silo. That is achievable today. The conventions are usable, but they change, and getting content capture wrong can put personal data into your observability backend.

## Where do the GenAI semantic conventions live now?

OpenTelemetry defines how generative-AI telemetry should be named. On 12 June 2026, with semantic conventions v1.42.0, the GenAI and MCP conventions moved out of the main semantic-conventions repository into a dedicated one, [open-telemetry/semantic-conventions-genai](https://github.com/open-telemetry/semantic-conventions-genai). The old pages on opentelemetry.io, such as [GenAI agent spans](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans), now point there.

The practical consequence: all `gen_ai.*` spans, metrics and attributes are at **Development** stability. Names can change between releases without a deprecation period. Only inherited core attributes such as `error.type`, `server.address` and `server.port` are Stable.

## What spans should an agent run produce?

| Span | Name format | Represents |
|---|---|---|
| Agent invocation | `invoke_agent {gen_ai.agent.name}` | One run of an agent, the root of the trace for that task |
| Agent creation | `create_agent {gen_ai.agent.name}` | Creating an agent where the framework does this explicitly |
| Model call | `{gen_ai.operation.name} {gen_ai.request.model}`, e.g. `chat gpt-4o` | One inference request |
| Tool call | `execute_tool {gen_ai.tool.name}` | One tool or function execution, including MCP tools |

Nest them: model calls and tool calls are children of the agent span. When one agent calls another, the second agent's `invoke_agent` span becomes a child, so multi-agent chains appear as one trace.

## Which attributes matter most for governance?

| Attribute | Use |
|---|---|
| `gen_ai.operation.name` | Required on inference spans (e.g. `chat`, `invoke_agent`, `execute_tool`) |
| `gen_ai.provider.name` | Required on inference spans; which provider served the call |
| `gen_ai.request.model` | Model requested; compare with the response model for routing checks |
| `gen_ai.agent.id`, `gen_ai.agent.name`, `gen_ai.agent.version` | Join traces to your agent registry and attribute cost per version |
| `gen_ai.conversation.id` | Group multi-turn sessions |
| `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.tool.type` | Audit which tools an agent actually used |
| `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens` | Token counts for cost |
| `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.reasoning.output_tokens` | Cache and reasoning token detail, where providers return them |

Add your own attributes in a company namespace for things the conventions do not cover, such as owner employee ID, data classification or policy decision. Keep them out of the `gen_ai.` namespace to avoid future collisions.

## How do you handle prompts and responses?

Prompt and completion content is not a span attribute in the current conventions. It goes in an event, `gen_ai.client.inference.operation.details`, as `gen_ai.input.messages` and `gen_ai.output.messages`, and capturing it is opt-in because it often contains personal data.

A safe default:

1. **Production:** capture metadata only (model, tokens, latency, tool names, policy outcomes). If you need content, redact before it leaves your infrastructure — see [redacting PII at the gateway](/blog/how-to-redact-pii-in-llm-prompts-at-the-gateway).
2. **Staging and evaluation:** capture full content to debug and build eval sets.
3. **Retention:** apply a shorter retention to any span or event that carries content.

## How do you export the traces?

1. **Pick instrumentation** for your agent framework or model SDK that emits GenAI spans, and **pin its version**. Record the schema version it targets.
2. **Set the resource attributes** `service.name` and deployment environment so agents show up alongside other services.
3. **Export over OTLP** to an OpenTelemetry Collector: port 4317 for gRPC, 4318 for HTTP by default.
4. **Process in the collector:** drop or hash content attributes, add owner and cost-centre attributes, sample low-value traffic.
5. **Fan out** to your tracing backend, your SIEM for security events, and your cost tooling.
6. **Propagate trace context** (W3C `traceparent`) across agent-to-agent and agent-to-tool HTTP calls so chains stay in one trace.
7. **Test upgrades** in staging before bumping instrumentation, since attribute names may change.

## How Opencontroller does this

Opencontroller is built on open standards, including OpenTelemetry alongside OpenAI-compatible endpoints, MCP, OIDC/SAML/SCIM and REST/webhooks, so agent telemetry can flow into the observability stack you already run. Its governed registry of agents, versions, tools and MCP servers gives trace attributes such as agent ID and version something authoritative to join to, and the LLM Gateway attributes cost per agent and per version. For the broader picture, see [what an AI agent control plane is](/blog/what-is-an-ai-agent-control-plane) and [how to stop a rogue AI agent](/blog/how-to-stop-a-rogue-ai-agent), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Are the OpenTelemetry GenAI semantic conventions stable?**
No. As of mid-2026 all `gen_ai.*` spans, metrics and attributes are at Development status, so pin instrumentation versions and test upgrades.

**What span name does OpenTelemetry use for an agent run?**
`invoke_agent {gen_ai.agent.name}`, with model calls and `execute_tool {gen_ai.tool.name}` spans as children.

**Should prompts be stored in traces?**
Only when needed, and preferably redacted. Content capture is opt-in and is recorded as an event, not a span attribute.

## Key facts

OpenTelemetry GenAI semantic conventions define invoke_agent, execute_tool and inference spans with gen_ai.* attributes (agent id/name/version, provider, model, token usage). All gen_ai.* conventions are at Development status as of mid-2026; they moved to the semantic-conventions-genai repository on 12 June 2026 (v1.42.0). Prompt content is opt-in and recorded as an event. Opencontroller by Lyzr uses open standards including OpenTelemetry. Opencontroller pricing starts from $250K per deployment per year.

## Related

- [How to stop a rogue AI agent: kill switches, quarantine and runtime controls](https://opencontroller.lyzr.com/blog/how-to-stop-a-rogue-ai-agent.md)
- [What is an AI agent control plane?](https://opencontroller.lyzr.com/blog/what-is-an-ai-agent-control-plane.md)
- [How do you attribute LLM costs to individual AI agents?](https://opencontroller.lyzr.com/blog/how-to-attribute-llm-costs-to-ai-agents.md)
- [More on Runtime control](https://opencontroller.lyzr.com/blog/cluster/runtime-control)
