---
title: "AI Gateway: OpenTelemetry GenAI Spans for Every Provider Call"
description: "AI Gateway traces now record an OpenTelemetry GenAI span for every LLM provider call, with model, token usage, cost, fallbacks, and opt-in prompt content."
canonicalUrl: "https://zuplo.com/changelog/2026/11/09/ai-gateway-opentelemetry-genai-spans"
pageType: "changelog"
date: "2026-11-09"
tags: "runtime"
---
AI Gateway traces now record an OpenTelemetry GenAI inference span for every
call to an LLM provider. Each span carries the model, provider, token usage,
cost, and outcome of that call, using the
[OpenTelemetry semantic conventions for generative AI](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/).
Backends that understand GenAI telemetry, such as Langfuse, Datadog LLM
Observability, Honeycomb, and Grafana, show model, token, and cost views without
any mapping.

- **One span per attempt**: the primary call, each fallback, quota fallbacks,
  and retries after a `429` each get their own span
- **Usage that matches billing**: token counts and cost come from the same
  metering as AI Gateway analytics and usage limits
- **Full streams**: a streamed response's span stays open until the last chunk
- **Content when you want it**: prompts and completions are recorded only when
  you turn on content capture

Spans appear for every sampled request as soon as the
[OpenTelemetry plugin](https://zuplo.com/docs/ai-gateway/observability/tracing)
is registered. There's nothing else to configure.

## See model calls, not just HTTP calls

Provider calls used to appear as plain HTTP spans, so a fallback looked like two
unrelated fetches. Each call is now a `CLIENT` span named `{operation} {model}`,
such as `chat gpt-5`, with the HTTP call to the provider nested under it.

![Before, upstream calls were plain HTTP spans; now each provider call is a GenAI inference span with model, usage, cost, and outcome.](../public/media/changelog/2026-11-09-ai-gateway-opentelemetry-genai-spans/trace-before-after.png)

Each inference span records:

- `gen_ai.provider.name`, `gen_ai.request.model`, and the request's sampling
  parameters
- The provider's own `gen_ai.response.id`, `gen_ai.response.model`, and
  `gen_ai.response.finish_reasons`
- `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and cache and
  reasoning tokens when the provider reports them
- `zuplo.ai_gateway.cost.usd`, priced with the same rates as your budgets and
  spend analytics
- `zuplo.ai_gateway.attempt`: `primary`, `fallback`, `quota_fallback`, or
  `retry`
- `error.type` on a failed attempt: the provider's status code, `timeout`, or
  the error name

The request span adds what the gateway decided: the model the client asked for,
`zuplo.ai_gateway.cache.status` for the semantic cache, and
`zuplo.ai_gateway.refused_by` with the name of the policy that rejected a
request.

## Streaming responses

The HTTP span ends when the provider starts streaming. The inference span stays
open until the stream finishes, then records token usage, cost,
`gen_ai.response.time_to_first_chunk`, and how the stream ended:
`zuplo.ai_gateway.stream.end` is `complete`, `error`, or `client_cancelled`.

![Timeline of a streamed request: the failed primary attempt, then a fallback span that stays open until the stream completes while its HTTP span ends at first byte.](../public/media/changelog/2026-11-09-ai-gateway-opentelemetry-genai-spans/stream-timeline.png)

## Capture prompts and completions

To record prompt and completion text on inference spans, set
`instrumentation.genAi.captureContent` to `true`:

```ts title="modules/zuplo.runtime.ts"
runtime.addPlugin(
  new OpenTelemetryPlugin({
    exporter: { url: environment.OTEL_TRACES_URL },
    instrumentation: { genAi: { captureContent: true } },
  }),
);
```

Content lands in `gen_ai.system_instructions`, `gen_ai.input.messages`, and
`gen_ai.output.messages`, each capped at 8 KiB. Input is recorded after policies
such as Data Loss Prevention mask it, and well-known credential formats are
replaced with placeholders.

## Getting started

Register the OpenTelemetry plugin on your AI Gateway and send traces to Zuplo or
your own backend. See
[AI Gateway tracing](https://zuplo.com/docs/ai-gateway/observability/tracing)
for setup, the full attribute reference, and example queries.