AI features fail with a 200 OK. Tracing model calls and tool calls with the OpenTelemetry GenAI conventions, and adding cost and quality signals, makes those failures visible.

A conventional service usually tells you when it fails. It throws, times out or returns a 5xx, and the dashboards turn red. An AI feature can fail while every one of those signals stays green. The model returns a fluent, wrong answer with a 200 status. An agent calls the same tool eleven times before giving up. A prompt change doubles the tokens per request and nobody notices until the invoice arrives.
The four golden signals from Google's SRE book (latency, traffic, errors and saturation) [7] still apply to AI applications. They are necessary and not sufficient. An AI request also needs a record of which model was asked what, which tools it called, how many tokens it spent and whether the result was any good.
OpenTelemetry already gives most teams the plumbing: traces made of spans, metrics and logs, exported to whatever backend they use. What it adds for AI workloads is a set of semantic conventions for generative AI, so that a model call recorded by one library looks the same as a model call recorded by another [1].
A single user request to an agent might produce a trace like this:
POST /api/assistant (HTTP server span)
└── invoke_agent support-agent (agent span, INTERNAL)
├── chat example-model (inference span, CLIENT)
├── execute_tool lookup_order (tool span, INTERNAL)
│ └── SELECT orders ... (database span)
├── chat example-model (inference span, CLIENT)
└── execute_tool create_case (tool span, INTERNAL)
└── POST /cases (HTTP client span)
The span names follow the conventions. An inference span SHOULD be named {gen_ai.operation.name} {gen_ai.request.model}, for example chat followed by the model name, and SHOULD have kind CLIENT when the model runs in another process [2]. A tool span SHOULD be named execute_tool {gen_ai.tool.name} with kind INTERNAL [3]. An agent invocation SHOULD be named invoke_agent {gen_ai.agent.name} when the name is available, with kind INTERNAL for an agent running in the same process and CLIENT for a remote agent service [4]. The model name above is a placeholder.
The value of the tree is that the AI spans sit inside the ordinary ones. The database query that a tool ran, and the HTTP call that created a case, appear under the tool span that caused them. When an answer is wrong, you can see whether the model misread good data or was handed bad data.
The GenAI conventions define many attributes. A useful first set for an inference span, using the names in the current specification [2]:
| Attribute | Why record it |
|---|---|
gen_ai.operation.name (required) | Separates chat, embeddings, tool execution and agent spans in queries |
gen_ai.provider.name (required) | Groups calls by provider when more than one is in use |
gen_ai.request.model and gen_ai.response.model | The model you asked for and the model that answered can differ |
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens | The basis of every cost calculation |
gen_ai.usage.cache_read.input_tokens, gen_ai.usage.reasoning.output_tokens | Explain cost changes that the headline token counts hide |
gen_ai.response.finish_reasons | A finish reason of length often means a truncated answer that looks complete |
gen_ai.request.max_tokens, gen_ai.request.temperature | Configuration drift shows up here before it shows up in quality |
gen_ai.conversation.id | Correlates the calls of one conversation; the spec says not to invent one if none exists |
gen_ai.prompt.name, gen_ai.prompt.version | Ties a quality change to a prompt change |
error.type | Required when the operation ended in an error |
The specification also says that gen_ai.operation.name, gen_ai.provider.name, gen_ai.request.model, server.address and server.port SHOULD be set when the span is created, because samplers may need them to decide whether to keep the trace [2]. For tool spans, gen_ai.tool.name is required and gen_ai.tool.call.id links the tool span back to the model output that requested it [3].
The example below is illustrative. It shows the attributes as a backend might display them, not the output of a particular SDK, and every value is invented.
# Illustrative only: two spans from one agent turn, values invented.
- name: 'chat example-model'
kind: CLIENT
attributes:
gen_ai.operation.name: chat
gen_ai.provider.name: example-provider
gen_ai.request.model: example-model
gen_ai.response.model: example-model-v2
gen_ai.request.max_tokens: 1024
gen_ai.response.finish_reasons: ['tool_use']
gen_ai.usage.input_tokens: 2140
gen_ai.usage.output_tokens: 96
gen_ai.prompt.name: support-triage
gen_ai.prompt.version: '14'
server.address: api.example.com
- name: 'execute_tool lookup_order'
kind: INTERNAL
attributes:
gen_ai.operation.name: execute_tool
gen_ai.tool.name: lookup_order
gen_ai.tool.type: function
gen_ai.tool.call.id: call_abc123
app.tenant.id: tenant-42 # application attribute, not a GenAI convention
The last attribute is an application-specific one. Tenant, feature and customer tier are not part of the GenAI conventions, but they are what turns a token count into a cost per tenant or per feature. Keep them outside the gen_ai.* namespace, which belongs to the specification.
The GenAI conventions as a whole, and every gen_ai.* attribute in them, are marked Development, not Stable [1][2]. Only general attributes reused from the core conventions, such as error.type and server.address, are Stable. That status is visible in practice:
gen_ai.system; later releases use gen_ai.provider.name [5][6].OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental to switch to the latest ones [5].gen_ai.client.operation.duration and tokens in a single gen_ai.client.token.usage histogram [5]. In the new repository, inference has its own metrics, such as gen_ai.client.inference.duration and gen_ai.client.inference.usage.input_tokens [2], and gen_ai.client.token.usage is no longer defined there.The names in this article were checked against the main branch of the GenAI repository at commit 95aff9c, which had no tagged release when we checked it, so treat them as a snapshot of a Development specification. The practical consequence is a design judgement: pin the instrumentation versions you use, record which convention version they emit, and build dashboards on a thin layer of saved queries rather than on raw attribute names scattered across many panels. When the names change, you edit the queries, not every dashboard.
The most tempting thing to log is the full prompt and the full response. The specification treats this as sensitive. Instructions, user messages and model outputs "are considered sensitive", and instrumentations SHOULD NOT capture them by default but SHOULD offer an opt-in [3]. The attributes that hold content, such as gen_ai.input.messages, are marked Opt-In and carry a warning that they are likely to contain personal data [2].
The specification describes three patterns [3]:
In the current text, when content capture is configured through an environment variable, that variable MUST be named OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT, with values NO_CONTENT (default), SPAN_ONLY, EVENT_ONLY and SPAN_AND_EVENT [3]. Check which form the libraries you use support, because older instrumentations may use different switches.
Our default is the third pattern for production: content in a separate store with its own access policy and retention period, references on spans, and redaction before storage where the data allows it. Telemetry backends are often readable by far more engineers than the production database is. Whether a given retention period or region is acceptable under the data-protection law that applies to you is a question for counsel, not for the observability team. The wider security picture for prompts, tools and data boundaries is in secure architecture for AI applications.
Cost in an AI application is a function of tokens, and tokens vary per request in a way that CPU time on a typical API usually does not. OWASP lists unbounded consumption as one of its top ten risks for LLM applications, including "denial of wallet" attacks that run up usage-based bills, and recommends rate limits, quotas, input size limits and timeouts [8].
Telemetry is what makes those limits enforceable and tunable. A workable cost model is:
cost(request) = Σ over inference spans of
input_tokens × input_price(model)
+ output_tokens × output_price(model)
+ cache and reasoning adjustments, where the provider bills them separately
The prices belong in a table your team maintains, keyed by provider and model, because they change and differ by contract. Group the result by tenant, feature and prompt version. The spec advises grouping inference spans by service.name when counting operations or tokens, noting that one client request may involve several server-side inference operations [2]. In our reading, that grouping is also what stops a gateway and an application from both counting the same call.
Latency and cost tell you the system is running. They do not tell you it is right. Quality needs its own signals:
| Signal | Source | What it catches |
|---|---|---|
| Finish reason distribution | gen_ai.response.finish_reasons | Truncation and unexpected tool-use loops |
| Tool error and retry rate | execute_tool spans with error.type | Agents fighting a broken or slow tool |
| Tool calls per agent turn | Count of execute_tool children | Loops and wandering plans |
| Sampled grader scores | An evaluation job reading stored transcripts | Drift in answer quality after model or prompt changes |
| Explicit user feedback | Application events linked by trace ID | What users actually reject |
The grader row is where observability and evaluation meet. Anthropic's guidance on agent evaluation treats the transcript (the full record of tool calls and intermediate results) as the core artefact to read and grade [9]. A production trace with content stored safely is the same artefact. Sampling production traces into the evaluation set is how a failure seen once becomes a regression test, which is the approach described in evaluating AI agents beyond the demo.
| Step | Reason |
|---|---|
| 1. Propagate trace context through the AI path, including tools | Without one trace per request, nothing else can be joined |
| 2. Emit inference and tool spans with the required attributes | Gives latency, errors and tokens per call with no content risk |
| 3. Add tenant, feature and prompt-version attributes | Turns raw tokens into cost and quality per thing you manage |
| 4. Set budgets and alerts on tokens per tenant and per request | Unbounded consumption is a listed risk, and bills arrive late [8] |
| 5. Decide the content policy, then enable capture | Content is sensitive and off by default for good reason [3] |
| 6. Sample traces into an evaluation job | Quality signals need graders, not just counters |
| 7. Pin convention versions and review them on upgrade | The conventions are in Development and names have changed [1][5] |
This order front-loads the steps that carry no privacy risk and defers the one that does until a policy exists. It is also the order in which we would set up AI telemetry as part of cloud and DevOps engineering work, so that the platform team owns the plumbing and the product team owns the quality signals.
Prepared with AI-assisted research and drafting.
[1] OpenTelemetry, "Semantic conventions for generative AI systems" (docs/gen-ai/README.md), semantic-conventions-genai repository, main branch at commit 95aff9c, 2026. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/README.md
[2] OpenTelemetry, "Semantic conventions for generative AI client inference" (docs/gen-ai/client-inference.md), semantic-conventions-genai repository, main branch at commit 95aff9c, 2026. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/client-inference.md
[3] OpenTelemetry, "Semantic conventions for generative client AI spans" (docs/gen-ai/gen-ai-spans.md), semantic-conventions-genai repository, main branch at commit 95aff9c, 2026. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-spans.md
[4] OpenTelemetry, "Semantic Conventions for GenAI agent and framework spans" (docs/gen-ai/gen-ai-agent-spans.md), semantic-conventions-genai repository, main branch at commit 95aff9c, 2026. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-agent-spans.md
[5] OpenTelemetry, "Semantic conventions for generative client AI spans" and "Semantic conventions for generative AI metrics", semantic-conventions repository, release v1.41.1, 2026. https://github.com/open-telemetry/semantic-conventions/tree/v1.41.1/docs/gen-ai
[6] OpenTelemetry, semantic-conventions repository, docs/gen-ai at releases v1.36.0 and v1.42.0, 2025–2026. https://github.com/open-telemetry/semantic-conventions/tree/v1.36.0/docs/gen-ai and https://github.com/open-telemetry/semantic-conventions/tree/v1.42.0/docs/gen-ai
[7] R. Ewaschuk (B. Beyer, ed.), "Monitoring Distributed Systems", in Site Reliability Engineering, Google, 2017. https://sre.google/sre-book/monitoring-distributed-systems/
[8] OWASP GenAI Security Project, "LLM10:2025 Unbounded Consumption", OWASP Top 10 for LLM Applications 2025, 2025. https://genai.owasp.org/llmrisk/llm102025-unbounded-consumption/
[9] Anthropic, "Demystifying evals for AI agents", Anthropic Engineering, 2026. https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents