LLM observability: tracing, cost, evals and OpenTelemetry in 2026

LLM observability: tracing, cost, evals and OpenTelemetry in 2026

LLM observability is the practice of recording what your AI application sends to models, what comes back, how long it took, what it cost and whether the answer was good, so you can debug and improve it in production. This guide covers what to log, how tracing works for agents, cost and latency metrics, evals on live traffic, the OpenTelemetry GenAI conventions and the main tools.

In shortTL;DR
  • Record every model call as a trace span with model, token counts (including cache), latency, finish reason, prompt version and errors.
  • Use the OpenTelemetry GenAI semantic conventions (gen_ai.* attributes) so your data works in any backend; they are still in Development status, so pin versions.
  • Treat prompt and response content as sensitive: it is opt-in in the conventions and off by default in the official instrumentations.
  • Track cost per feature and per successful outcome, not only per request, and watch p95 latency and time to first token.
  • Run evals on a sample of live traces and turn bad traces into regression tests.

What is LLM observability?

LLM observability is the practice of capturing enough detail about every model call and agent step (inputs, outputs, tokens, latency, cost, errors and quality) that you can explain why your AI feature behaved the way it did. It extends classic application observability with the things that make LLM apps different: non-deterministic outputs, per-token pricing, and multi-step agent loops.

A normal web request either works or throws an error. An LLM request can return HTTP 200 with a wrong answer, a refusal, a response cut off at the token limit, or a ten-step agent loop that cost a dollar to answer a simple question. None of those show up in a standard error-rate graph.

The same three signals from general observability still apply, plus one more:

SignalWhat it answers for an LLM appExample
TracesWhat happened in this request, step by step?Retrieval, 3 model calls, 2 tool calls, total 8.4 s
MetricsHow is the system behaving overall?p95 latency, tokens per minute, spend per day
Logs and eventsWhat exactly was sent and received?Prompt, response, tool arguments (opt-in)
EvalsWas the output any good?Faithfulness score, schema validity, user thumbs-down

Monitoring and observability work together. Monitoring watches known numbers and alerts you. Observability lets you open the trace behind the alert and see the bad retrieval or the runaway tool loop.

What should you record for every LLM call?

Record one span per model call with the model, token counts, latency, finish reason, prompt version and error status, and attach the user-facing request it belongs to. Those fields answer most production questions about cost, speed and failures.

FieldWhy you need itOpenTelemetry attribute
Provider and operationGroup and compare providersgen_ai.provider.name, gen_ai.operation.name
Requested and actual modelSpot silent model changes and aliasesgen_ai.request.model, gen_ai.response.model
Input and output tokensCost and context growthgen_ai.usage.input_tokens, gen_ai.usage.output_tokens
Cached tokensCheck that prompt caching worksgen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_write.input_tokens
Reasoning tokensSee how much of the output is thinking (counted inside output tokens)gen_ai.usage.reasoning.output_tokens
Finish reasonCatch truncation and refusalsgen_ai.response.finish_reasons
Request settingsReproduce a responsegen_ai.request.max_tokens, gen_ai.request.temperature
Prompt template and versionTie regressions to prompt changesgen_ai.prompt.name, gen_ai.prompt.version
ConversationFollow a session across callsgen_ai.conversation.id
ErrorsRate limits, timeouts, bad requestserror.type plus span status
Prompt and output contentDebug specific answersgen_ai.input.messages, gen_ai.output.messages (opt-in)

Two fields people skip and later regret: the prompt version, because most quality regressions follow a prompt edit, and the finish reason, because a response that stopped on the token limit looks fine in a latency chart. If you return structured data, also record schema validation failures and retries; our guide to LLM structured output explains why they still happen.

How does tracing work for LLM apps and agents?

A trace is a tree of spans: one root span for the user's request, with child spans for each retrieval, model call and tool call inside it. For agents, the tree shows every loop iteration, so you can see where time and tokens went.

The OpenTelemetry GenAI conventions define well-known operation names for these spans, including chat, embeddings, retrieval, execute_tool, invoke_agent and create_agent. A support agent's trace might look like this:

trace for one user question
POST /api/support                                9.2 s└─ invoke_agent support-agent                    9.0 s   ├─ retrieval kb-articles                      0.4 s   ├─ chat claude-sonnet-5-5                     2.1 s   in 6,240 / out 180 tokens   ├─ execute_tool lookup_order                  0.3 s   ├─ chat claude-sonnet-5-5                     2.4 s   in 6,710 / out 95 tokens   ├─ execute_tool lookup_order                  0.3 s   (same arguments again)   └─ chat claude-sonnet-5-5                     3.3 s   in 7,150 / out 410 tokens

This trace shows two problems that no metric would: the agent called the same tool twice with the same arguments, and input tokens grew on every turn because the whole history was resent. The fixes (deduplicating tool calls, caching the stable prefix) come straight from reading it. For agent design patterns behind traces like this, see our overview of AI agent frameworks.

What are the OpenTelemetry GenAI semantic conventions?

The OpenTelemetry GenAI semantic conventions are a shared set of span names, attribute names and metrics for model calls, agents, tools and retrieval, so that instrumentation from one library works in any backend. As of November 2026 they live in their own repository, semantic-conventions-genai, and are marked Development, which means names can still change.

The basics are settled in practice:

  • Span name: {gen_ai.operation.name} {gen_ai.request.model}, for example chat claude-sonnet-5-5.
  • Span kind: CLIENT for calls to a model provider.
  • Required attributes: gen_ai.operation.name and gen_ai.provider.name (for example anthropic, openai, gcp.gemini, aws.bedrock).
  • Content attributes such as gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions and gen_ai.tool.definitions are Opt-In, and the spec warns they are likely to contain sensitive information.
  • Provider pages cover differences. The Anthropic page notes that Anthropic's input_tokens excludes cached tokens, so gen_ai.usage.input_tokens should be the sum of uncached, cache-read and cache-write input tokens.

Metrics are where the churn shows. Older instrumentations emit gen_ai.client.token.usage and gen_ai.client.operation.duration; the current client inference page defines gen_ai.client.inference.duration, gen_ai.client.inference.time_to_first_chunk and separate token metrics such as gen_ai.client.inference.usage.input_tokens. The released conventions ask instrumentations to let you opt in to the latest experimental version with OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental; without it they keep emitting the version they already emitted. Build dashboards on the version your libraries actually emit, and check it when you upgrade.

Note

Several projects, such as OpenLLMetry, OpenInference and OpenLIT, defined their own LLM attribute names before or alongside the official conventions. Check which attributes a library sends before you mix two of them in one backend.

How do you instrument an LLM call with OpenTelemetry?

Use an instrumentation library for your SDK when one exists, and add a manual span where it doesn't. Either way, the span carries the gen_ai.* attributes from the previous section.

The quickest path is auto-instrumentation. OpenLLMetry, an Apache-2.0 project built on OpenTelemetry, instruments OpenAI, Anthropic, vector databases and more after pip install traceloop-sdk and a call to Traceloop.init(). The OpenTelemetry project also ships official Python GenAI instrumentations, such as opentelemetry-instrumentation-genai-anthropic and opentelemetry-instrumentation-genai-openai; they do not capture prompts and completions by default, and OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT (for example span_only) switches content capture on.

When you need control, a manual span is short. This example wraps an Anthropic call and follows the conventions, including the cached-token rule:

traced_call.py
import anthropicfrom opentelemetry import tracefrom opentelemetry.trace import SpanKindtracer = trace.get_tracer("support-bot")client = anthropic.Anthropic()MODEL = "claude-sonnet-5-5"def answer(question: str) -> str:    with tracer.start_as_current_span(f"chat {MODEL}", kind=SpanKind.CLIENT) as span:        span.set_attribute("gen_ai.operation.name", "chat")        span.set_attribute("gen_ai.provider.name", "anthropic")        span.set_attribute("gen_ai.request.model", MODEL)        span.set_attribute("gen_ai.request.max_tokens", 1024)        span.set_attribute("gen_ai.prompt.name", "support-answer")        span.set_attribute("gen_ai.prompt.version", "v12")        try:            response = client.messages.create(                model=MODEL,                max_tokens=1024,                messages=[{"role": "user", "content": question}],            )        except anthropic.APIError as err:            span.set_attribute("error.type", type(err).__name__)            raise  # the context manager records the exception and sets ERROR status        usage = response.usage        cache_read = usage.cache_read_input_tokens or 0        cache_write = usage.cache_creation_input_tokens or 0        span.set_attribute("gen_ai.response.id", response.id)        span.set_attribute("gen_ai.response.model", response.model)        span.set_attribute("gen_ai.response.finish_reasons", [response.stop_reason])        # Anthropic's input_tokens excludes cached tokens; the convention wants the total.        span.set_attribute("gen_ai.usage.input_tokens", usage.input_tokens + cache_read + cache_write)        span.set_attribute("gen_ai.usage.cache_read.input_tokens", cache_read)        span.set_attribute("gen_ai.usage.cache_write.input_tokens", cache_write)        span.set_attribute("gen_ai.usage.output_tokens", usage.output_tokens)        return "".join(b.text for b in response.content if b.type == "text")

Export the spans with the standard OTLP exporter. Most LLM observability backends accept OTLP directly; Langfuse, for example, receives traces on its /api/public/otel endpoint, so you point OTEL_EXPORTER_OTLP_ENDPOINT at it and add the auth header.

Rows of server racks in a data center
Every model call is a network request to someone else's servers; trace it like any other dependency

How do you track LLM cost and latency?

Compute cost from token counts on each span, then aggregate by feature, customer and model; for latency, watch p95 and time to first token rather than averages. Both numbers drift as prompts grow and agents take more steps.

For cost, multiply each token type by its price from your provider's pricing page: uncached input, cache reads, cache writes and output (reasoning tokens are usually billed as output). Store the result on the span or compute it in your backend, and keep the price table versioned, because prices change. Then build these views:

  1. Cost per feature or route, so you know which product surface spends the money.
  2. Cost per successful outcome, such as per resolved ticket or per merged pull request. A cheap request that needs three retries is not cheap.
  3. Cache hit share: cache-read tokens divided by total input tokens. A sudden drop usually means something volatile, like a timestamp, crept into the prompt prefix.
  4. Top spenders: the 1% of requests with the most tokens. They are usually runaway agent loops or oversized context.
  5. Budget alerts per project and per day.

For latency, total duration hides what users feel. Track time to first token for streaming responses, p95 and p99 duration per route, and the number of model calls per request for agents, since each extra loop adds seconds.

Our guide to reducing LLM API costs covers what to do once you can see the spend, and prompt caching is usually the first lever. If your spend comes from coding agents rather than your own app, Orkio's Insights shows what agents cost per project, per model and per merged pull request, with project budgets and alerts.

Should you log prompts and model outputs?

Log content deliberately: it is the most useful data for debugging and the most sensitive data you hold. Decide what to capture, where it is stored, who can read it and when it is deleted before you turn it on.

The OpenTelemetry conventions mark all content attributes as opt-in for this reason. Practical rules:

  • Sample. Capture full content for a percentage of traffic plus every error, refusal and low eval score.
  • Redact emails, phone numbers, account numbers and secrets before export, in a collector processor or in your code.
  • Store content separately. The conventions define _ref attributes, such as gen_ai.input.messages_ref, that point to content in external storage instead of putting it on the span.
  • Set shorter retention for content than for metrics.
  • Restrict access to traces that contain content, and log who views them.
  • Check where the backend runs. If prompts contain customer data, a hosted tool is a data processor; self-hosting is an option with open-source backends.
Warning

Tool arguments and tool results count as content too. An agent that reads a customer record puts that record into the trace if you capture gen_ai.tool.call.result.

How do you run evals on production traffic?

Run automated checks on a sample of live traces, collect user feedback on the rest, and turn every bad trace you find into a test case. Production evals tell you about quality drift that offline test sets miss, because real users ask things you didn't anticipate.

A workable setup has four layers:

LayerWhat it checksRuns on
Deterministic checksSchema validity, length, forbidden strings, citations presentEvery response
LLM-as-judgeFaithfulness to retrieved context, tone, task completionA sample, such as 1 to 5%
User feedbackThumbs up or down, edits, retries, escalationsWherever the UI allows
Regression setKnown hard cases built from bad tracesEvery prompt or model change

Attach eval scores to the trace, not to a separate spreadsheet, so you can filter "low faithfulness" and open the exact retrieval and prompt behind it. When a model or prompt version changes, compare score distributions before and after. Judges are models too: spot-check their verdicts against human labels before you trust them for alerts. Our guide to LLM evaluation goes deeper on building the test set and the judge.

Which LLM observability tools should you use?

Pick a backend that accepts OpenTelemetry, so your instrumentation is not locked to one vendor, then choose between self-hosted open source and a hosted service based on where your prompt data may live. Most tools now cover tracing, cost views and evals; they differ in hosting, license and how you send data.

ToolTypeHow data gets inLicense
LangfuseTracing, prompt management, evalsSDKs and OTLP endpointMIT core, separate license for enterprise directories; self-host or cloud
Arize PhoenixTracing and evalsOpenTelemetry-based instrumentationElastic License 2.0 (source-available)
OpenLLMetryInstrumentation librariesOpenTelemetry SDK, any OTLP backendApache-2.0
HeliconeAI gateway plus observabilityChange the base URL to its gatewayApache-2.0
Your existing OTel stackGeneral observabilityOTLP from any GenAI instrumentationDepends on vendor

Commercial platforms such as LangSmith and Datadog LLM Observability cover similar ground with hosted dashboards. Two questions narrow the choice fast: can prompt content leave your infrastructure, and do you already pay for an observability backend your team knows? A proxy or gateway like Helicone needs no code changes beyond the base URL but adds a network hop; SDK and OpenTelemetry instrumentation adds code but no extra hop.

How to set up LLM observability this week

Start with traces and cost on one feature, then add content sampling and evals once the basics are flowing.

  1. Pick a backend that accepts OTLP, or use the OpenTelemetry stack you already have.
  2. Add an instrumentation library for your model SDK, or the manual span above.
  3. Make sure every span has model, provider, token counts with cache, finish reason and prompt version.
  4. Build three charts: spend per day by feature, p95 latency and time to first token, error and truncation rate.
  5. Set a daily budget alert and a latency alert.
  6. Turn on content capture for a small sample and for errors, with redaction and short retention.
  7. Add one deterministic check and one sampled LLM-as-judge eval, and review the worst ten traces every week.

Frequently asked questions

What is the difference between LLM monitoring and LLM observability?

Monitoring tracks known signals such as error rate, latency and spend, and alerts when they cross a threshold. Observability records enough detail about each request, including the full trace of model and tool calls, that you can explain a problem you did not predict. In practice you need both, built from the same trace data.

Is OpenTelemetry ready for LLM observability?

The OpenTelemetry GenAI semantic conventions are usable and widely adopted, but as of November 2026 they are still marked Development, and metric names have changed recently. Use an instrumentation library rather than hand-naming everything, and pin the convention version you emit.

Should I log full prompts and responses?

Only with a deliberate decision about privacy and retention. Prompts and outputs often contain personal data, which is why the OpenTelemetry conventions make them opt-in. Many teams log content for a sample of traffic, redact known identifiers, and keep it for a shorter period than metrics.

What metrics matter most for an LLM application?

Start with request volume, error rate, p50 and p95 latency, time to first token for streaming, input and output tokens including cached tokens, cost per feature, and the share of responses that stop on the token limit. Add a quality metric from evals or user feedback as soon as you can.

Do I need a dedicated LLM observability tool?

Not always. If you already run an OpenTelemetry stack, you can send GenAI spans to it and build dashboards there. Dedicated tools add LLM-specific views such as conversation replay, prompt versioning and built-in evals, which save time once you have real traffic.

SOURCES

  1. OpenTelemetry GenAI semantic conventions (repository)
  2. OpenTelemetry GenAI conventions: client inference spans and metrics
  3. OpenTelemetry GenAI conventions: Anthropic
  4. OpenTelemetry Python GenAI: Anthropic instrumentation README
  5. Langfuse docs: OpenTelemetry
  6. OpenLLMetry (Traceloop) repository
  7. Helicone repository
  8. Arize Phoenix repository
  • #llm observability
  • #opentelemetry
  • #tracing
  • #llmops
Orkio team

The team building Orkio. We write about putting AI to work: coding agents that run overnight, always-on boxes and pull requests ready by morning.

Keep reading

All posts

07:06 · YOU MERGED #128

Go to sleep. Wake up to pull requests.

Start for $19 a month
© 2026 Orkio · Hosted in Europe TürkçeStatus