Record every agent run as one trace: a tree of timed spans, one for the run, one for each model call and one for each tool call. Everything else on this page (cost, sampling, redaction, scores) reads the attributes on those spans, so what you put on them decides what you can answer later.
Why: a run's final answer does not say which step failed, cost too much or took too long. Observability means recording enough about every step, while it runs, to answer questions you did not think to ask beforehand.
Fig. 1, step by step: the local run of the running example (8 model calls, 7 tool calls), then the path its spans take
invoke_agent textstats-fixer opens first and closes last; every span of the run hangs under it and shares its 128-bit trace id.chat spans, each as long as the call took on the shared local server (call 4 waited 78 s) and as tall as its prompt: the context grows from 424 to 1,545 tokens as tool results pile up.execute_tool spans (list_files, read_file twice, edit_file twice, run_tests twice), each after the call that asked for it; milliseconds long, drawn at a minimum width. What happened: sections 1 to 3.tests_pass = 1 onto this trace; low scores feed a dataset that gates the next change (section 9).You need spans, context propagation and head against tail sampling in general: Observability: logs, metrics, traces, alerting owns them. The parent root's section 7 and its Production stack tab give the overview (one trace rendered and priced, a small eval gate). This page is the agent- and LLM-specific layer.
gen_ai.*)The running example is the one used across the agent pages: a small Python repository, textstats, with two planted bugs and the instruction "The tests in this repository fail. Find out why and fix the code so they pass. Do not edit the tests." The user message starts with a fake customer, "Hi, this is Dana Reyes (dana.reyes@example.com, customer ACCT-4417-2290)", so we can see where personal data ends up. Everything is measured on this page's own runs unless it says otherwise MEASURED.
claude -p, Claude Code 2.1.291, the same task) with Claude Code's beta tracing on, launched from a small Python "application" that passes its trace context down, so one trace covers three processes.--setting-sources project --strict-mcp-config --no-session-persistence), mlx-community/Qwen3-4B-Instruct-2507-4bit on mlx-lm 0.32.0. Scripts, collector configurations, redacted recordings and data are in this page's src/.Neighbours that own what this page only names: GPU counters, goodput and GPU-hour chargeback are on Observability and cost; how to grade agent runs is on Agent and trajectory evaluation; gates, golden sets and online scoring budgets are on Production eval engineering; judge design on LLM-as-judge.
The problem. The local run made model calls and 7 tool calls in a loop. A log line per call gives a list that cannot say which model call asked for which tool, which calls belonged to which run when two runs interleave, or how long the run waited on the model against running tools.
How a trace answers it. Each span has a name, a start and end time, a parent span (none for the root), a status (unset, ok or error), attributes (key-value pairs such as the model name and token counts) and optional events (timestamped notes inside the span). The program creates spans through the OpenTelemetry API; an exporter ships finished spans over OTLP (the OpenTelemetry protocol) to a collector or straight to a backend that stores and draws them (Langfuse, Jaeger, Datadog and many others).
The same recorded run, three ways (beside this text). Predict first: what does a popular client auto-instrumentation give you for this run? The card opens on the finished run; switch the view, then step through the same recorded run three ways, operation by operation. Logs: print statements. Auto spans: one span per model call, each in a trace of its own. Agent trace: one root span for the run, a child for each model call and each tool call.
Timings are the real run's: each model call's bar is how long the shared local server took to answer it (other agents' load varied, so call 4 took 78 s). Tool calls took milliseconds and are drawn at a minimum width. Token counts are the server's.
Across processes. W3C Trace Context carries the trace id and the parent span id from one process to the next in a header, traceparent. Claude Code reads it from a TRACEPARENT environment variable in claude -p and Agent SDK sessions, and hands its own context to every Bash subprocess in the same variable (Claude Code monitoring docs). A small "application" opened a span for a ticket and started Claude Code under it; a python3 wrapper on the PATH turned the inherited TRACEPARENT into a span for the test runner MEASURED (beside this text).
One trace id, three services, spans: the ticket and the agent invocation from the application, Claude Code's interaction, model requests and tool spans, and two process tests/test_core.py spans from the test runner, each under the claude_code.tool.execution span of the Bash call that started it. No shared database or request id; the context travelled in an environment variable. The header byte by byte, and what goes wrong when a hop drops it: Observability: logs, metrics, traces, alerting.
Read of a directory (EISDIR, at 10.6 s) and a test run that exited non-zero (ShellError, at 19.0 s). Both are normal in an agent: a failed test run is how the agent learns what is wrong. Span status describes one operation, not the run's outcome. Section 7 shows what this does to error-based sampling. When everything fails, put a typed error on the root span, with the same trace id the user's request had, so the incident is one query away.The problem. If one library writes the model under model, another under llm.model_name and a third under gen_ai.request.model, a backend cannot compute cost or group by model without a mapping for each. The GenAI conventions are OpenTelemetry's agreed names for model calls, agents and tools.
Where they live and how stable they are. In 2026 they moved out of the main conventions repository into their own, open-telemetry/semantic-conventions-genai. This page pins commit cb10b70 (5 Oct 2026) and reads the machine-readable model files (spans.yaml, registry.yaml, metrics.yaml), not the prose. Its manifest declares stability: development and schema gen-ai-dev/1.42.0-dev, built on the main conventions v1.44.0. "Development" means names can still change without a deprecation period; packages that already follow the latest draft ask you to opt in with OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental (see the research notes in src/inputs/research.md) SOURCE.
Span types. The model defines span types and values of gen_ai.operation.name. Three of them carry an agent run:
| Span | Name format | Kind | One per |
|---|---|---|---|
invoke_agent | invoke_agent {gen_ai.agent.name} | INTERNAL when the agent runs in your process, CLIENT when you call a remote one | agent run (the root of an agent trace) |
chat (an inference span) | {gen_ai.operation.name} {gen_ai.request.model} | CLIENT (INTERNAL allowed for a model in the same process) | model call |
execute_tool | execute_tool {gen_ai.tool.name} | INTERNAL | tool call |
The others cover the rest of an LLM application: create_agent, invoke_workflow (a multi-agent or multi-step workflow), plan, retrieval, embeddings, fetch_response (reading a stored response back), and memory operations (search_memory, create_memory and five more). Explore any of them in the explorer beside this text.
Three rules that matter in practice.
gen_ai.operation.name and gen_ai.provider.name are required; gen_ai.request.model is required "if available"; token counts are only recommended. A span can follow the conventions and still be useless for cost.opt_in: by default the conventions record that a call happened, not what was said. Section 8 measures which libraries respect that.Counting tokens. The registry says gen_ai.usage.input_tokens "SHOULD include all types of input tokens, including cached tokens", with gen_ai.usage.cache_read.input_tokens and gen_ai.usage.cache_write.input_tokens as subsets of it. Anthropic's API counts differently, so the Anthropic section adds: "Anthropic input_tokens excludes cached tokens. Compute: gen_ai.usage.input_tokens = input_tokens + cache_read_input_tokens + cache_write_input_tokens". On the first model call of our Claude Code run that is the difference between two very different numbers (drawn to scale beside this text):
input_tokens (not cached)gen_ai.conversation.id groups the calls of one multi-turn conversation (Langfuse turns it into a session, measured below); gen_ai.prompt.name and gen_ai.prompt.version record which version of a managed prompt produced a call (the link a prompt registry needs); gen_ai.conversation.compacted marks a call made after the history was compacted; gen_ai.request.reasoning.level carries an effort setting. On a structured-output retry loop (validate, feed the error back, retry two or three times at most; Typed agent libraries covers Pydantic AI's ModelRetry), record a span or event per retry with the validation error and watch the retry rate: a rising rate is a prompt or model regression.
Metrics. The same commit defines histograms, among them gen_ai.client.operation.duration, gen_ai.invoke_agent.duration, gen_ai.invoke_agent.inference_calls and gen_ai.invoke_agent.tool_calls. The last two are the ones to alert on for agents: a jump in model calls per run is the earliest sign of an agent looping (put the stop reason of a step, token or wall-clock budget on the root span too; budgets themselves are on Building a harness). Token usage metrics are in a separate token-metrics.yaml, as counters such as gen_ai.client.inference.usage.input_tokens and .cache_read.input_tokens; the earlier gen_ai.client.token.usage histogram is no longer defined there, so dashboards built on older instrumentation need renaming (development-status names still move: pin the version). For a serving engine the same files define gen_ai.server.time_to_first_token ("Time to generate first token for successful responses") and gen_ai.server.time_per_output_token.
The names are still moving. The provider attribute used to be gen_ai.system; it is now gen_ai.provider.name, and gen_ai.system does not appear in this repository's registry at the pinned commit. Check what your backend maps before trusting a dashboard; section 6 is what happens when you do not.
opentelemetry-instrumentation-openai-v2 2.4b0 still writes only gen_ai.system (so its spans miss a required attribute), Pydantic AI writes both, Claude Code 2.1.291 writes gen_ai.system plus its own token names (input_tokens, cache_read_tokens, cache_creation_tokens; since 2.1.300, 14 October 2026, its spans also carry gen_ai.provider.name, gen_ai.conversation.id and gen_ai.tool.name, per the changelog), and OpenInference uses a different convention altogether (llm.token_count.prompt, input.value) MEASURED.The three ways. Manual instrumentation is code you write: open a span, set attributes, close it. Auto-instrumentation is a package that patches a client library (here the openai Python client) so every call it makes produces a span, with no change to your code. Framework-native instrumentation is built into an agent framework, which knows where its own runs and tool calls begin and end.
We replayed the identical recorded run through the same loop eight ways: hand-written spans with and without content, OpenTelemetry's own opentelemetry-instrumentation-openai-v2 with and without its content switch, Traceloop's OpenLLMetry, Arize's OpenInference, Langfuse's drop-in OpenAI client, and the same agent rewritten in Pydantic AI with its built-in instrumentation. All sent their spans both to a local file and to the self-hosted Langfuse MEASURED:
"Model calls / tools / root": spans of each kind. "Traces": how many trace ids the one run was split into. "Fake PII": occurrences of the fake customer's e-mail and account id in span attributes (and, for openai-v2, in its log events). "KB": total attribute size, a proxy for storage cost. "Langfuse": the observation types Langfuse stored. Every span, attribute by attribute: tab Eight instrumentations.
What the table says.
TRACELOOP_TRACE_CONTENT=false to stop it; Pydantic AI's InstrumentationSettings(include_content=True) is the default).input.value and flattened into one attribute per message field), reached KB.cached_tokens). OpenLLMetry, OpenInference, Langfuse and Pydantic AI recorded them; openai-v2 and our first hand-written version did not, so a backend would price those tokens as fresh input. A trace with the messages is how you check what a framework really sends. The sibling page LangChain and LangGraph recorded create_agent's first request and found it is exactly your system prompt, the user message and the tool schemas, with nothing added; the parent's Same agent, six ways tab found Pydantic AI's structured output arrives through an added final_result tool (details on Typed agent libraries) and smolagents sends a 2,231-token system prompt of its own. Those findings came from logging the requests; with content capture on, your tracing backend shows the same thing for every run.
What to do. Use auto-instrumentation for the model client (it captures parameters, tokens and errors you would forget) and add the agent skeleton yourself: one invoke_agent span around the run and one execute_tool span around each tool call, both with the conventions' names, so the client spans nest under them. If a framework already does it, as Pydantic AI does, use that. Decide content capture deliberately, per environment: on in evaluation runs, where graders need the arguments and results; off or redacted in production.
What it is. Langfuse is an open-source platform for tracing, evaluating and managing prompts of LLM applications: MIT-licensed except its ee/ folders (LICENSE). ClickHouse announced it had acquired Langfuse on 16 January 2026, saying it "stays open source and self-hostable" (ClickHouse blog). Version 4 became generally available on 17 August 2026 (changelog); the latest release when we ran it was 4.53.0, published that morning (releases) SOURCE.
What it took to run. Langfuse's own Docker Compose file at tag v4.53.0, ports moved to localhost: six containers (web, worker, ClickHouse 25.12, Postgres 17, Redis 7, MinIO for S3-style blob storage), about GB of images, and GiB of memory at rest after ingesting this page's traces MEASURED.
The data model. A trace is one request or run; it contains observations, typed as span, generation (a model call), event, agent, tool, chain, retriever, evaluator, embedding or guardrail (observation types). Traces group into sessions and are attributed to users; scores attach to traces or observations. Version 4 rebuilt storage around one wide, mostly immutable ClickHouse table, in which "traces are represented as root spans within the same table instead of a separate entity", and replaced the old batch ingestion API with OpenTelemetry (v3 to v4 upgrade guide).
Fig. 2, step by step: the six containers as run here, one batch of spans through them
langfuse-web at /api/public/otel, with the project's public and secret key as HTTP Basic auth. The same container serves the UI and the API.langfuse-web puts each batch on it and langfuse-worker takes it off, turns spans into observations and runs evaluators.events_only deployment, the old GET /api/public/traces, /observations and /scores endpoints answer 404 with "This endpoint is not available on deployments running in Langfuse v4 events_only mode", while /api/public/v2/observations and /api/public/v3/scores work MEASURED.How OpenTelemetry spans become observations. Every variant's model calls became generations with the model and token counts, whatever names it used; no cost was computed for any of them, because Langfuse has no price for a local model, which is correct.
Langfuse accepts OTLP at /api/public/otel with the project's public and secret key as HTTP Basic auth. Its mapping, from its docs: the observation type comes from langfuse.observation.type, then gen_ai.operation.name, then "model present means generation"; the model from gen_ai.request.model, llm.model_name or model; usage from gen_ai.usage.* or llm.token_count.* (OpenTelemetry integration). What it stored from our eight variants MEASURED:
Every variant's model calls became generations with the model and token counts, including OpenInference's llm.* names and Langfuse's own langfuse.observation.* attributes. Langfuse also split cached tokens out of the input into a separate input_cached_tokens bucket (its usage keys are non-overlapping: "each token must be counted in exactly one key", docs). Our hand-written gen_ai.conversation.id became the session id, and Pydantic AI's became a session too. No cost was computed for any of them: Langfuse has no price for a local model, which is correct. The Claude Code run in section 6 is where prices come in.

call_llm span (table below). Credit: Langfuse GmbH, langfuse-docs, MIT licence, source.Langfuse's other halves (from its docs, used only where marked): scores and datasets (section 9, measured); LLM-as-a-judge evaluators that run on observations as they arrive ("observation-level evaluators are the recommended target for live production data; trace-level evaluators are deprecated", docs); prompt management, where labels such as production and staging point at prompt versions and an unlabelled fetch serves production (docs); masking in the SDK before export (mask_otel_spans in the Python SDK v4); and sampling in the SDK (sample_rate, decided per trace).
With a gateway. If your model calls already go through LiteLLM, its langfuse_otel callback sends a GenAI span per request to the same endpoint with usage and cost, and LiteLLM now recommends it over the older langfuse callback (LiteLLM docs) SOURCE. Gateway spans see every request but not the agent around it; app spans see the agent. Run both and join them on the trace id. After a retry or a fallback the deployment that answered may not be the one the app asked for; the LiteLLM proxy names it in the x-litellm-model-id response header, so copy that onto the model span and the trace shows which deployment answered (Gateways and routing, section 2, which counts that header to check a routing strategy). Retries, cooldowns and fallbacks themselves are its section 3. Evaluate every model in a fallback chain, or a fallback is a silent quality cliff.
All of these accept OpenTelemetry, so the cheapest insurance is to instrument with OpenTelemetry and treat the backend as configuration. They differ in what they put first, who can run them, and the licence. Facts checked on 6 October 2026 against each vendor's own docs and repositories (not run here except Langfuse) SOURCE:
| Tool | Leads with | Run it yourself | Licence | Its unit of work | Notes |
|---|---|---|---|---|---|
| Langfuse | Tracing, then prompts and evals | Yes, six containers (above) | MIT outside ee/ | Trace of typed observations | Owned by ClickHouse since Jan 2026; v4 is OpenTelemetry-only ingestion |
| LangSmith | Tracing and evals for LangChain and LangGraph | Only as an Enterprise add-on (docs) | Platform proprietary; SDKs MIT | A run ("a single unit of work"), a trace (runs of one operation), a thread (a multi-turn session) (concepts) | OTLP at /otel/v1/traces; LangGraph Studio became LangSmith Studio on 14 Oct 2025 |
| Braintrust | Evals: an eval is data, a task and evaluators (docs) | Hybrid: you run the data plane, Enterprise only (docs) | Proprietary | Experiment; trace of typed spans | Online scoring of production logs at a sampling rate; OTLP at api.braintrust.dev/otel |
| Arize Phoenix | Tracing and evals, strong on retrieval | Yes (Docker, Kubernetes) | Elastic License 2.0: source-available, not open source in the OSI sense (LICENSE) | OpenInference spans (openinference.span.kind: LLM, TOOL, AGENT, ...) | Since 15.10.0 (15 May 2026) converts GenAI-convention spans to OpenInference on ingest (release note); Arize AX is the commercial tier |
| OpenLLMetry (Traceloop) | Not a backend: instrumentation for many providers, vector stores and frameworks | Library | Apache 2.0 | OpenTelemetry spans | Traceloop acquired by ServiceNow (reported 2 Mar 2026; ServiceNow called it "recently completed" on 5 May 2026, press release) |
How to choose. If you need the data on your own machines and do not want an Enterprise contract, the choice is Langfuse or Phoenix; read Phoenix's licence before offering it as a service. If your agent is LangGraph and you are happy with a hosted service, LangSmith understands its runs best (see LangChain and LangGraph). If your bottleneck is "is version 3 better than version 2" rather than debugging, Braintrust is built around that question. Whatever you pick, keep a collector in front so you can switch or send to two at once.
When the vendor runs the loop, the spans between your request and its result are produced inside the vendor's process and you see only what they export. Treat trace export as a procurement question: what is exported, in which conventions, with what content, and for how long it is kept.
| Runtime or SDK | What you can trace |
|---|---|
| OpenAI Agents API (public beta 10 Sep 2026) | Exports per-session traces as OTLP JSON: GET /v1/agents/sessions/{session_id}/traces; attribute conventions not stated (docs) |
| Claude Managed Agents (public beta 8 Apr 2026) | No OpenTelemetry export found; an event log per session (span.model_request_start and _end, tool use, session.usage with 5-minute and 1-hour cache-write counts) and a session viewer in the Console |
| OpenAI Agents SDK | Tracing on by default, sent to OpenAI's traces dashboard, not OpenTelemetry; unavailable under Zero Data Retention; replace with set_trace_processors() or disable with OPENAI_AGENTS_DISABLE_TRACING=1 |
| Google ADK | OpenTelemetry GenAI spans (invoke_agent, execute_tool, generate_content); Google's own guide recommends ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS=false. ADK 2.13.0 (22 Oct 2026) defaults to the GenAI conventions v2 and drops its older call_llm span (the release notes call it removed in the highlights, deprecated in the changelog); ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN=otel_semconv_1_36 keeps the old schema, so dashboards and queries keyed on call_llm need changing or that switch (release notes) |
| Claude Code | Beta tracing (sections 1 and 6) plus OpenTelemetry metrics and events; since 2.1.307 a claude_code.safety_event event for each tool call that a permission rule, auto mode, a safety check, a hook or the sandbox stopped, prompted or sent back, so blocked actions can be counted and alerted on beside cost (changelog) |
Sources for each row are in src/inputs/research.md; the runtimes themselves are compared on the parent's Production stack tab.
The problem. The bill says what you spent; it does not say which agent, user, feature or step spent it. A trace can, if each model span carries the model and the token counts by kind, and the backend multiplies them by the right prices. Two things go wrong in practice: the counts arrive under names the backend does not read, and the prices the backend applies are not the ones you paid.
The experiment. The Claude Code run reported total_cost_usd = for turns (an API-price equivalent; the subscription paid). We sent its recorded trace to Langfuse three times through a collector, changing only how the token counts were labelled MEASURED:
total_cost_usd = for the run: fresh input, cache-write (all 1-hour), cache-read and output tokens across 8 model calls.llm_request spans and made them generations, but found no gen_ai.usage.* attributes (Claude Code names its counts input_tokens, cache_read_tokens, cache_creation_tokens), so usage was empty and cost $0.gen_ai.usage.input_tokens as the sum of all three input kinds, plus cache_read and cache_write. Langfuse split them into buckets and priced them: , % short, because the cache writes were priced at the 5-minute rate.usage_details attribute with the key input_cache_creation_1h. Langfuse now prices the writes at 2x: , equal to the reference.claude_code.cost.usage metric, summed over its delta exports, is : one total, no breakdown by kind.Three independent totals agree. The run's own total_cost_usd, Langfuse's sum over generations once the counts carried their cache duration, and Claude Code's claude_code.cost.usage metric (delta temporality, summed over its exports) all give . The formula, with Haiku 4.5's list prices per million tokens (input $1, 1-hour cache write $2, cache read $0.10, output $5; Anthropic pricing):
The 16% gap in step 3 is cache-write tokens priced at the 5-minute rate (1.25x) instead of the 1-hour rate (2x) that Claude Code used on these runs (ephemeral_1h_input_tokens in its usage, and in the shared facts for the agent pages). The GenAI conventions have one cache_write count and no field for the cache's lifetime, so a backend that follows them faithfully must guess; Langfuse's model table has separate input_cache_creation_5m and _1h prices, so passing the count under the explicit key fixed it. An open Langfuse issue reports the same mispricing from its LangChain integration (#17450).
Rolling cost up. Once each model span has a correct cost, attribution is a group-by over the trace: by the root's attributes for user, ticket and feature (our application set app.user, app.ticket, app.feature on its span), by gen_ai.conversation.id for a session, by span name for a step. Langfuse propagates user, session and tags to every observation when you set them with propagate_attributes() (its Python SDK v4, the one used here; Python SDK v5, a major release on 14 October 2026, comes with a v4 to v5 migration guide, so check it before copying v4 code). Reconcile against a second source: the gateway's spend log, the provider's invoice, or, as here, the harness's own metric. Two sources that disagree by a fixed ratio usually mean a price or a token kind is wrong, as in step 3 above. Other usual causes of a gap: cache reads counted as fresh input, a model name that matches no price entry, and spans that were sampled away or lost.
Do not count twice. If the agent span carries the run's total tokens under the same names as the model spans, a backend that sums all spans counts them twice. Pydantic AI writes the totals on its agent span as gen_ai.aggregated_usage.* for this reason (its use_aggregated_usage_attribute_names setting, default on).
Haiku 4.5 list prices per million tokens: input $1, 5-minute cache write $1.25, 1-hour cache write $2, cache read $0.10, output $5 (Anthropic pricing). The "check" column recomputes each call at the 1-hour rate.
The problem. Keeping every trace costs storage and money, and with content on a single run of our small task was 30 to 100 KB of attributes. Sampling keeps a subset. Head sampling decides when the root span starts (usually "keep 10% of trace ids") and is cheap, but cannot know whether the run will fail. Tail sampling decides after seeing the spans, so it can keep every failure; in OpenTelemetry it is the collector's tail_sampling processor, which holds a trace's spans in memory for decision_wait (30 s by default) after the first one arrives, evaluates its policies once, and then forwards or drops (processor README at v0.162.0). The general mechanics are on Observability: logs, metrics, traces, alerting; here is what is different about agents.
Agent traces break three assumptions. They are long (minutes, hours for some harnesses), so a fixed wait decides before the run ends. Their root span ends last, so the outcome arrives last. And their spans fail routinely: our successful Claude Code run already had two ERROR spans (section 1). We replayed that run's 49 spans into a real collector at their recorded end times (29 s from first to last), after marking its final tool execution and its root as failed, through four tail-sampling setups that all keep "any trace with an ERROR span" MEASURED:
decision_wait at 5 s it will decide at 5.1 s, on whatever has arrived by then.decision_wait is 300 s, so the wait itself never decides.decision_wait_after_root_received).Ticks on the timeline: spans as they arrive (red: status ERROR; the last two were marked failed by us). Measured on otelcol-contrib 0.162.0.
The setting made for this case is decision_wait_after_root_received: wait as long as you like (300 s here), but decide shortly (2 s) after the root span arrives.
And the policy must look at the run, not at any span. We replayed the same trace twice more, once marked failed and once exactly as recorded (a success with two recoverable errors), through two policies that both wait for the root MEASURED:
| Policy | Failed run | Successful run |
|---|---|---|
status_code: [ERROR] on any span | (kept, wrongly) | |
ottl_condition: IsRootSpan() and span.status.code == STATUS_CODE_ERROR |
The application has to say whether the run failed, on the root span: an ERROR status or an attribute such as app.outcome. Our first attempt at the root condition, parent_span_id.string == "", matched nothing and raised no error (the policy's error_mode: ignore swallowed it); only the empty output file showed it. Test a sampling policy with a known failing trace before you trust it.
Soft failures need scores, not status. The worst agent failures end with status OK: the tests pass but the agent edited the tests, or the answer is wrong. No status-based rule keeps those. Keep a small random share of everything (so you can estimate rates), every run whose root says failed, and every run an online evaluator scored low (section 9); count runs with metrics, which are computed before sampling. Langfuse's SDK can also sample, per trace, with sample_rate (docs).
The recorded Claude Code trace, 49 spans arriving at their real end times over 29 s, the root last. The simulator applies the processor's documented rules to these arrival times; each preset is an outcome measured on the real collector (six collector pipelines, seven outcomes), and the simulator is checked against every one. Predict first: at what wait does the failed run start being kept?
Late spans: in our runs the collector still held the trace's decision in memory, so spans arriving after a "drop" were dropped too, with or without the decision cache. Under heavy load, once a trace is evicted from the buffer without a decision cache, late spans are "buffered for decision_wait seconds and then a new sampling decision is made" (processor README), which yields a fragment of the trace instead. The simulator shows the measured behaviour.
The problem. A trace with content holds every prompt, every tool argument and every tool result. In an agent that means customer messages, file contents, shell output and the paths of the machine it ran on, copied to a second system with its own access rules and retention. Prompts were opt-in in the conventions for exactly this reason.
What leaked in our runs MEASURED:
user_prompt = <REDACTED>), tool inputs and tool output, but puts the account identity on every span: user.email, user.account_uuid, user.id and organization.id were on all of its spans. The docs say user.email and organization.id are "always included when available"; the OTEL_METRICS_INCLUDE_* switches cover only session id, account uuid, version, entrypoint and repository (see src/inputs/research.md). If a trace leaves the developer's machine, that is personal data in every span.OTEL_LOG_USER_PROMPTS=1, OTEL_LOG_TOOL_DETAILS=1, OTEL_LOG_TOOL_CONTENT=1), the prompt with the customer's e-mail appeared on the interaction span, file paths on tool spans, and tool.output span events held file contents, diffs and shell output. The operating-system login name appeared times outside the identity attributes: in absolute file paths (the working folder sits under the home folder) and in the output of an ls -la the agent ran, where the file-owner column is the login name. The content-on trace carried % more attribute bytes than the default run's (52 spans against 49).Where to remove it, in order of preference. (1) Do not capture it: leave content off in production and turn it on per environment. (2) Mask in the SDK before export (Langfuse's mask_otel_spans, a custom span processor), which only covers that SDK's spans. (3) Redact in a collector you control, before data leaves your network, which covers every service at once. We measured three collector policies with the redaction processor (beta for traces) on the content-on Claude Code trace and on the content-on hand-instrumented trace (beside this text; pick a policy):
What the measurement says. Masking by pattern caught every e-mail, the account ids and every path, in span attributes and in span event attributes alike, and still missed the login name in ls -la output, because no pattern described it. A keyed hash (hmac-sha256) does the same job while keeping values joinable: the same e-mail always becomes the same digest, so you can still count one customer's runs. The allow-list of keys removed everything not on the list ( attributes on the Claude Code trace) and left nothing to leak, at the price of the content you wanted to debug with. A deny-list fails open on whatever you did not think of; an allow-list fails closed. In production, use the allow-list and keep full content only where access is controlled and retention is short. The attack side of the same problem (prompt injection, exfiltration through tools) is on Agent security.
Collector otel/opentelemetry-collector-contrib:0.162.0 in Docker. Each configuration passed otelcol-contrib validate before use. Two lessons from writing them: an hmac_key shorter than 32 bytes is rejected for hmac-sha256; and an OTTL condition that matches nothing does not fail, so test policies with a trace you know should match.
The idea. Traces are the raw material for evaluation. Online evaluation scores a sample of production traces as they arrive, with code checks where they can decide and a model judge where they cannot, and writes the result back onto the trace as a score. Offline evaluation reruns a fixed dataset of tasks before every change; interesting production traces get promoted into that dataset. The same trace store serves debugging, monitoring and regression testing, which is the main argument for an integrated platform over plain OpenTelemetry.
What we ran. A 55-line scorer read each run's outcome and wrote four rule-based scores to Langfuse through its API (tests_pass, summary_complete, turns, and cost_usd for the Claude run), then read scores back from /api/public/v3/scores. We also created a dataset and promoted the local run's trace into it as an item with sourceTraceId set and an expected output MEASURED.
Fig. 3, step by step: one trace store serves debugging, monitoring and the regression gate
tests_pass and summary_complete (0 or 1), turns (8, 8 and 13) and cost_usd ($0.0421 for the Claude run; none for the local model). Eleven scores, read back from the API.summary_complete is 1, yet its summary names only one of its two fixes (the box below). A score is only as good as the check behind it.sourceTraceId pointing back at it and an expected output.tokenize change; it mentions the second one only as a test name ("including the apostrophes test, ties handling"). Our keyword rule looked for "tie" and scored the summary complete. Cheap checks drift from what they mean; check them against labelled cases (here: the diff contains two changes, the summary names one), and use a judge or a stricter structured check where a keyword cannot decide.Making it a loop. Sample live traces for scoring (vendor docs suggest 1 to 10% for high volume, more for critical paths, and the judge bill is a budget line: figures on Production eval engineering); alert on score rates and on the agent metrics from section 2 (model calls and tool calls per run, cost per run, p95 duration); promote failures to the dataset; gate every prompt, model, tool or harness change on that dataset. The parent's Production stack tab runs a small gate over 18 recorded runs. How to grade a trajectory rather than a final answer: Agent and trajectory evaluation; judge design and biases: LLM-as-judge; alert design: Observability: logs, metrics, traces, alerting. Version prompts outside code and promote them by label after the gate; with gen_ai.prompt.name and gen_ai.prompt.version on every model span, a regression can be traced to a prompt version (Langfuse's labels in section 4; gates on Production eval engineering).
/otel/v1/traces; the SDK is optional.langfuse_otel callback.effort span attribute and managed-settings event: confirmed (September 2026).The recorded local-model run of the running example ( model calls, 7 tool calls), replayed byte for byte from a small server that answers with the recorded responses, through the same Python loop instrumented eight ways. Tools ran for real on a fresh copy of the repository each time, so results were identical. Every span was written to a file by an extra exporter and sent to the self-hosted Langfuse. Pick a variant beside this text to see its spans on one time axis, then a span below. How this fits together is in the Reading tab, sections 2 to 4.
invoke_agent root and execute_tool children; Langfuse then typed them as agent, generation and tool observations.gen_ai.provider.name (it writes the older gen_ai.system) and has no content by default; with its content switch on, the messages went to log events rather than span attributes, which a traces-only backend never receives.gen_ai.usage.cache_read.input_tokens, plus its own extras (gen_ai.openai.api_base, the server's system_fingerprint, which here named the server's OS version).gen_ai.aggregated_usage.*, so a backend summing gen_ai.usage.* over all spans does not double count, and records the full message history on the agent span (pydantic_ai.all_messages).src/code/agent.py MODE and agent_pai.py against replay.py serving the recorded exchanges (redacted copy in recordings/local_run_exchanges.jsonl); run_variants.sh runs them all; compare.py classifies the spans; lf_fetch.py reads Langfuse back.Classification against the GenAI conventions at commit cb10b70. Attribute values are shown for the first span of each kind (later spans of the same kind repeat them); keys are shown for every span. Values over 90 characters are cut. The fake customer's e-mail and account id are the page's own test data.
First model-call span of each variant. OpenInference and Langfuse's client use their own names for the same facts (llm.model_name, llm.token_count.prompt; langfuse.observation.model.name, langfuse.observation.usage_details), which Langfuse and Phoenix both read; a backend that only knows the GenAI names would see nothing.
Links checked on 6 October 2026. Times are estimates for a careful read.
One replayed agent run instrumented eight ways: every span and attribute, classified against the GenAI conventions, and what Langfuse stored. About 4 min to read, 15 to explore.
The root. Its Reading section 7 is this page's summary; its Production stack tab renders one OpenTelemetry trace, prices it and runs a small eval gate over 18 recorded runs; its Same agent, six ways tab shows what each framework sends to the model. Reading 24 min, plus 2 closed; labs 18 to 21 min each.
Graphs, checkpointers and create_agent; LangSmith's home stack. About 34 min.
The Claude Code loop as a library: options, hooks, sessions, cost accounting. About 29 min.
Pydantic AI, OpenAI Agents SDK, smolagents, Google ADK, including their tracing defaults (the Agents SDK traces model and tool inputs and outputs by default, section 4) and structured output. About 24 min.
Orchestrator-workers, handoffs, debate; deep trace trees and token accounting across agents. About 32 min.
LiteLLM and OpenRouter: fallbacks, budgets, rate limits, and the gateway side of cost attribution; tag spans with the deployment that answered (section 2). About 34 min.
How a complete agent works inside; its Trace and context lab reads 22 Claude Code runs. About 21 min.
Hooks, permissions, headless runs and the stream-json format these traces mirror. About 43 min.
The loop, tool calling, stop conditions and budgets: what the root span should record. About 41 min.
Prompt caching, 1-hour writes and what they cost; its section 8 holds memory across sessions (Mem0, Zep, Letta), which absorbed the former child page Agent memory layers. About 35 min.
The attack side of data in traces: injection and exfiltration, defences. About 35 min.
Trajectories as training data: formats, redaction and filtering. About 36 min.
The general engineering: context propagation byte by byte, head and tail sampling, metrics, SLO alerts, on-call. About 39 min.
The machines under the model calls: GPU counters and what they really measure, goodput, alerts on hangs, GPU-hour chargeback and capacity. About 28 min.
Grading actions, not messages; what to log for graders. About 30 min.
Gates, golden sets, online scoring rates and budgets, shadow and A/B tests. About 30 min.
Judge design, biases and calibration for online evaluators. About 29 min.
lm-eval-harness, Inspect and app-level tools such as promptfoo and Braintrust. About 26 min.
Runtime rails, including personal data in inputs and outputs. About 39 min.
The source of truth; read model/gen-ai/spans.yaml and registry.yaml for requirement levels, and docs/gen-ai/ for prose. About 40 min.
The readable version; check it against the repository, which moves faster. About 25 min.
Data model, OpenTelemetry mapping, cost tracking, evaluators, prompts, self-hosting. About 40 min for the core pages.
What changed in storage and ingestion, and what still works. About 15 min.
Metrics, events, beta traces, the content switches and the always-on identity attributes. About 30 min.
decision_wait, decision caches, sampling strategies, every policy type. About 20 min.
Allow-lists, blocked values, hashing and the audit attributes. About 15 min.
Runs, traces, threads; with its OpenTelemetry page. About 20 min.
Phoenix's conventions (span kinds, flattened messages). About 20 min.
Instrumentation for many providers and frameworks; its privacy page for turning content off. About 15 min.
A market survey from 9 Aug 2026 (third-party; not checked claim by claim here). About 15 min.
How this page was made: two Claude Code runs (Claude Haiku 4.5 on the Claude subscription) and one local-model run (eight requests to Qwen3-4B-Instruct-2507 4-bit on a shared mlx-lm server, each under a lock), all on 6 October 2026; every other experiment replayed those recordings with no model. Scripts, collector configurations, redacted recordings and data are in this page's src/.