OpenTelemetry for LLMs: Vendor-Neutral AI Tracing

OpenTelemetry for LLMs: Vendor-Neutral AI Tracing

What happens when a chatbot gives a wrong answer at 2 a.m. and nobody can explain why? Traditional monitoring tools shrug. They can tell you the server was up and the database responded in 40 milliseconds, but they cannot tell you which prompt was sent, which model version replied, or how many tokens that answer quietly burned. That blind spot is exactly what OpenTelemetry for LLMs is trying to close. (What is OpenTelemetry? (Official Documentation))

Why LLM Observability Is a Different Problem

Classic application monitoring assumes a predictable request path. A user clicks a button, a service queries a database, and a response comes back. LLM calls break that model in several ways. They are slow and variable, they cost money per token rather than per request, and their output quality depends on free-text input that no schema can fully describe.

OpenTelemetry (often shortened to OTel) is a vendor-neutral, open-source framework of APIs, SDKs, and a collector for generating and exporting traces, metrics, and logs. It was formed in 2019 by merging OpenTracing and OpenCensus, and it is now a graduated project under the Cloud Native Computing Foundation. If you want the full picture of what the framework covers beyond AI, the official OpenTelemetry overview explains its components and design goals in plain language.

The appeal for AI teams is simple. Instead of wiring your application to one observability vendor’s proprietary agent, you emit standard telemetry once and send it anywhere: an open-source backend, a commercial platform, or both at the same time. That portability matters enormously in a field where tooling changes every few months.

The GenAI Semantic Conventions, Explained

The GenAI Semantic Conventions, Explained

Telemetry is only useful if everyone agrees on what to call things. That is the job of semantic conventions, OpenTelemetry’s standardized attribute names and structures. Without them, one team records `model_name` and another records `llm.model`, and no dashboard can compare the two. (Large language model)

The Generative AI semantic conventions define a shared vocabulary for LLM operations. The core attributes include `gen_ai.system` (which provider or framework produced the telemetry), `gen_ai.request.model` (the model being called), and `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` (token accounting). The conventions also cover request parameters such as temperature and maximum tokens, plus response metadata.

Span names follow a predictable pattern: `{gen_ai.operation.name} {gen_ai.request.model}`, which produces something like `chat gpt-4`. That naming discipline is what lets you group every chat call to a given model into a single latency chart without writing custom parsing logic.

There is an important caveat. The GenAI conventions have been published with Development status, meaning they are explicitly not stable and breaking changes are permitted. Attribute names have shifted between spec versions. Anyone building long-lived instrumentation should pin the semantic convention version they target and read the current GenAI semantic conventions specification before assuming a field name will survive the next release.

What a Traced LLM Call Actually Looks Like

A single user question often fans out into several operations. A retrieval-augmented generation pipeline, for instance, might embed the question, search a vector store, rerank results, assemble a prompt, call the model, and post-process the answer. OpenTelemetry models this as a trace made of nested spans, where each span records one timed operation with its own attributes.

In practice, a well-instrumented RAG request looks like this in the trace view:

Span What it captures
`embeddings text-embedding-3-small` Vectorization latency and input token count
`retrieval vector-db` Query time, number of documents returned
`chat gpt-4o` Prompt tokens, completion tokens, finish reason, temperature
`tool execute search_api` External tool call duration and status

The payoff is diagnostic. If latency spikes, the trace tells you whether the model slowed down, the vector search got sluggish, or a tool call hung. Metrics complement traces here: token-usage histograms keyed by model and operation let you watch spend trends over time rather than inspecting individual requests.

Instrumentation Options and Their Trade-Offs

There are two broad routes into OTel for LLM workloads, and choosing between them is the first real decision most teams face.

Auto-instrumentation wraps popular Python and JavaScript LLM SDKs so that calls emit spans without code changes. It is fast to adopt and good enough for a first look at latency and token usage. The downside is limited control: you get the attributes the instrumentation library chose to emit, which may lag behind the latest spec.

Manual instrumentation means creating spans yourself around model calls and adding attributes deliberately. It takes more work but gives you exactly the data you want, including business context like tenant ID, feature name, or prompt template version.

A few practical notes from teams that have done this:

  • Start with auto-instrumentation to get baseline traces within an afternoon.

  • Add manual spans only where auto-instrumentation leaves gaps, such as retrieval steps or custom routing logic.

  • Pin your instrumentation library versions, because the underlying conventions are still moving.

  • Test your dashboards against a spec upgrade before rolling it out broadly.

One common mistake deserves calling out. Many teams assume that any tool advertising “OTel compatibility” will produce identical attribute schemas. It will not. Several LLM observability platforms emit or accept OTel-compatible traces, but they differ in how closely they track the evolving `gen_ai.*` conventions. Two systems can both be “compatible” and still disagree on field names. Validate the actual payloads rather than trusting the label.

Using the Collector to Protect Prompts and Control Cost

The OpenTelemetry Collector is the standard component for receiving, processing, and exporting telemetry. It sits between your application and your backend, and for LLM workloads it earns its keep in two ways.

First, privacy. Prompts and completions routinely contain personal data, customer records, and internal documents. The GenAI conventions do include attributes for capturing input and output messages, but the spec treats full content capture as opt-in and privacy-sensitive rather than a default. The Collector is where most teams enforce that policy: strip or hash message bodies before export, keep only token counts and metadata, and route a sampled subset to a secure store for debugging. The Collector documentation covers the processor pipeline that makes this possible. (Blog)

Second, cost control. Verbose prompt logging multiplies storage bills fast. Sampling at the Collector, rather than in application code, keeps the decision in one place and lets you change it without redeploying services.

A sensible default that works in practice: capture full content only for errored requests and a small random sample of successful ones, and log metadata for everything else. That gives you debuggability without turning your observability backend into a shadow copy of your customer database.

Where the Standard Still Falls Short

Honesty matters here, because the gap between the marketing and the spec is real.

The GenAI conventions are not stable. Breaking changes are allowed, and they have happened. Teams that built dashboards on early attribute names have had to migrate them. Anyone claiming a fully settled standard for LLM telemetry is overselling.

Coverage is also uneven. Span conventions arrived before metrics conventions, and agentic workflows, multi-step tool use, and streaming responses are still being worked out. Evaluation results, which matter enormously for LLM quality, have no universally agreed representation in the spec yet.

The practical response is architectural rather than defensive. Keep your instrumentation thin and your business logic separate, so a spec change means editing a mapping layer rather than rewriting application code. Treat the semantic conventions as a moving target you track deliberately, not a foundation you build on blindly.

It also helps to follow the broader conversation. Project news and release notes are worth monitoring, and a news feed covering cloud and infrastructure developments is a reasonable way to catch spec milestones without watching repositories daily. Teams that share what they learn tend to adapt faster than teams that discover breaking changes in production. (News)

A Realistic Adoption Path

For a team starting today, a staged approach beats a big-bang rollout.

  • Week one: Enable auto-instrumentation for your main LLM SDK and export traces to a backend you already run. Confirm you can see model name, latency, and token counts.

  • Week two: Add manual spans around retrieval and tool calls so the trace reflects the whole pipeline.

  • Week three: Introduce the Collector, add a redaction processor for message content, and set sampling rules.

  • Week four: Build two or three dashboards that answer real questions, such as cost per feature and p95 latency by model.

  • Ongoing: Review the semantic conventions each quarter and adjust your mapping layer.

The order matters. Teams that start with dashboards before they have clean spans end up rebuilding everything. Teams that start with telemetry and add views later rarely regret it.

Conclusion

OpenTelemetry for LLMs is not a finished product, and it is not a magic wand. It is a shared vocabulary and a set of plumbing that lets you see what your AI features are actually doing, at what cost, and where they break. The GenAI conventions give you standard names for models, tokens, and operations. The Collector gives you a chokepoint for privacy and sampling. The vendor-neutral design means the data you collect today is not locked to a single platform tomorrow.

The teams getting value from this right now share a habit: they treat instrumentation as a product decision, not an afterthought. They decide what to capture, what to redact, and what to sample before the first prompt hits production. Given how fast the underlying models change, that discipline is the closest thing to a stable foundation available. If you want to keep pace with how the surrounding cloud and tooling landscape shifts, the cloud section is a good place to keep reading.

Frequently Asked Questions

What is OpenTelemetry in simple terms?

OpenTelemetry is an open-source toolkit for collecting traces, metrics, and logs from software. Instead of each vendor using its own agent, applications emit standard telemetry once and send it to any compatible backend. It was created in 2019 by merging two earlier projects and is now governed by the Cloud Native Computing Foundation. (Cloud)

Do I need OpenTelemetry specifically for LLM applications?

You do not need it, but it solves a real problem. LLM calls are expensive, slow, and hard to debug with traditional monitoring. OTel gives you a standard way to record model name, token usage, latency, and tool calls across providers, so you can compare them in one place instead of juggling separate vendor dashboards.

Are the GenAI semantic conventions stable enough for production?

Not fully. They carry Development status, which means breaking changes are permitted and attribute names have shifted between versions. Production use is fine, but pin your instrumentation versions and keep a thin mapping layer so a spec update does not force a rewrite of your application code.

Should I capture full prompts and responses in traces?

Usually not by default. Prompts and completions often contain personal data, and the specification treats full content capture as opt-in and privacy-sensitive. A common pattern is to log metadata for every request and retain full content only for errors and a small random sample, enforced at the Collector.

How much does LLM tracing cost to run?

Costs come from storage and processing, not from OpenTelemetry itself, which is free. Token-usage metrics are small and cheap to keep. Full prompt logs are the expensive part, so sampling and redaction at the Collector are the main levers for keeping bills predictable as traffic grows.

Can I switch observability backends later without re-instrumenting?

That is the main reason to adopt OTel. Because your application emits standard telemetry rather than vendor-specific payloads, you can point the exporter at a different backend by changing configuration. Some rework may be needed if attribute schemas differ, so validate payloads before you commit to a migration.

Latest articles

Scroll to Top