LLM tracing records what an LLM application does for one request as a trace: a tree of spans, where each span is one step such as a model call, a retrieval or a tool call. OpenTelemetry describes a span as a single unit of work, with a name, timing data and attributes that describe the operation. Reading a trace top to bottom shows what the application did and where a request slowed down or failed.

Traces and spans

OpenTelemetry says traces give the big picture of what happens when a request is made to an application. The parts that matter for LLM apps:

TermMeaning
TraceThe path of one request through the application, identified by a shared trace_id
Root spanThe span with no parent. It marks the beginning and end of the whole operation
Child spanOne step inside its parent, such as a tool call inside an agent run
AttributesKey-value metadata on a span, such as the model name
StatusOpenTelemetry defines three values: Unset, Error and Ok
Context propagationWhat OpenTelemetry calls the core concept that enables distributed tracing

Logs are different. OpenTelemetry notes that logs usually lack contextual information such as where they were called from, and become far more useful when attached to a span or correlated with a trace.

What an LLM trace contains

The OpenTelemetry GenAI semantic conventions define spans for the steps an LLM application takes. The conventions say GenAI spans represent logical operations as observed by the caller, and that a span covers the full logical operation including any automatic retries. The gen_ai.operation.name attribute lists the operation types:

OperationWhat the span covers
chat, generate_contentA model call
embeddingsAn embeddings request
invoke_agentAn agent run
create_agentCreating an agent, usually on a remote agent service
planAgent planning or task decomposition
execute_toolA tool execution (see tool calling)
invoke_workflowA workflow run

Span names follow patterns. A model call should be named {gen_ai.operation.name} {gen_ai.request.model}, and an agent invocation span should be named {gen_ai.operation.name} {gen_ai.agent.name} when the agent name is available, with span kind INTERNAL.

Model call spans also carry token counts. The inference conventions include gen_ai.usage.input_tokens and gen_ai.usage.output_tokens, so a trace can show token usage per model call.

What to record, and what not to

Prompts and outputs are the most useful data in a trace and the riskiest. The GenAI conventions state that model instructions, user messages and model outputs “are considered sensitive and are often large in size,” and that instrumentations should not capture them by default but should offer an opt-in.

The conventions describe three usage patterns:

  1. Record nothing. This is the default.
  2. Record content on the spans with gen_ai.system_instructions, gen_ai.input.messages and gen_ai.output.messages. The conventions say this suits manageable telemetry volume where privacy regulations do not apply or the storage complies with them, for example in pre-production environments.
  3. Store content externally and record references on the spans. The conventions recommend this for production environments where telemetry volume is a concern or sensitive data needs to be handled securely, because external storage allows separate access controls.

The conventions mark tool arguments and results, retrieval query text and prompt template variables as Opt-In attributes that may contain sensitive information.

Standards and tools

OpenTelemetry describes itself as the mechanism by which application code is instrumented to help make a system observable. Because the GenAI conventions sit on top of it, spans that follow them use the same trace and span model as the rest of a system’s telemetry. Tracing products may also read their own attribute schemes, so check which attributes a given tool expects before relying on one.

The GenAI conventions are still changing. The documents carry Development status, and the pages that used to live on the main OpenTelemetry site have moved to a separate GenAI conventions repository. Span names and attributes can change, so pin the instrumentation version you run.

How tracing connects to evaluation

Traces feed evaluation. Agent evaluation covers how to grade agent runs, and it cites LangChain’s advice to read 20 to 50 real traces before building eval infrastructure. RAG evaluation covers judging the retrieval step, which the GenAI conventions give its own retrieval span definition.

A post on this site, Using an agent to improve another agent, shows one workflow built on stored traces: pulling failed traces, grouping the failures and proposing small prompt changes.