---
title: Trace agent runs
description: "Every agent turn as one OpenTelemetry trace in the backend you already use: the run and its tool calls from the page, each model step from the server, with content off and redaction on by default."
sidebar:
  label: Overview
related:
  - /observability/installation
  - /observability/apis
  - /observability/privacy
---

When an agent misbehaves in production, you want to see what it did: which tools it called, how long the person took
to confirm, which model step was slow, how many tokens it spent. `@webmcp-agents/telemetry` records that as
OpenTelemetry spans and sends them to any backend that speaks OpenTelemetry.

:::note[Experimental]
`@webmcp-agents/telemetry` and the run events it is built on are new in 0.5.0, and the OpenTelemetry GenAI conventions
they follow are not stable yet. Span and attribute names may change in a minor release.
:::

## What one turn looks like

One message from the person is one trace. The page records the run and its tool calls; the server records each model
step. The two sides share the trace through the `traceparent` header the chat sends with every step, so a backend
shows them as one tree:

```mermaid
flowchart TD
  run["invoke_agent shopper<br/><small>page: the whole run</small>"]
  step1["chat claude-sonnet-5-5<br/><small>server: model step 1</small>"]
  tool["execute_tool add_to_cart<br/><small>page: one tool call</small>"]
  step2["chat claude-sonnet-5-5<br/><small>server: model step 2</small>"]
  run --> step1
  run --> tool
  run --> step2
```

**invoke_agent**

The run, from the page: the agent, how it ended, how many steps, the page's URL (redacted).

**chat**

One model step, from the server: the model, input and output tokens, the step number.

**execute_tool**

One tool call, from the page: its outcome, the wait for the person, whether they confirmed.

**invoke_agent (sub-agent)**

A sub-agent's run, under the tool call that delegated to it.

Every span carries `webmcp.conversation.id` and `webmcp.run.id`. Prompts, outputs and tool data are not recorded
unless you turn them on ([Privacy and redaction](/docs/observability/privacy)). The names and attributes are on
[Span names and types](/docs/observability/spans).

## How it works

1. **The server layer**

    `defineObservability()` goes on the chat handler. Every model step becomes a `chat` span, sent where the standard
    `OTEL_*` variables (or a provider your app already registered) say.

2. **The relay**

    The page posts its spans to your own `/api/telemetry`, which checks and redacts them again and forwards them
    through the same layer. The backend's key never reaches the browser.

3. **The page's observer**

    One component next to the chat turns each run and tool call into spans. Nothing loads until a run starts.

## Choose your backend

Pick one. Its installation page is the six steps for that backend, and every telemetry page after it shows what
differs for it.

{/* The backends, one card per installation page (docs/observability/installation/<id>.mdx). Edit them here, once:
   each title is the backend's <Tab> title on the observability pages and the name its page saves. Brand marks are
   Simple Icons 16.38.1 (CC0) paths; a backend Simple Icons has no mark for gets a Lucide icon, never a logo. */}

**[Any OTLP backend](/docs/observability/installation/otlp)**

Grafana, Honeycomb, SigNoz, Axiom, Jaeger or your own Collector, from the environment.

**[Arize](/docs/observability/installation/arize)**

Arize AX or Phoenix, through OpenInference's span processor.

**[Braintrust](/docs/observability/installation/braintrust)**

Its span processor, or the environment alone.

**[Datadog](/docs/observability/installation/datadog)**

The agentless OTLP intake, or the provider of `dd-trace`.

**[Helicone](/docs/observability/installation/helicone)**

The chat's model, logged on its way to the provider.

**[IBM Instana](/docs/observability/installation/instana)**

Agentless, or through the host agent, as protobuf.

**[Laminar](/docs/observability/installation/laminar)**

OTLP from the environment, as JSON or protobuf.

**[Langfuse](/docs/observability/installation/langfuse)**

Its span processor, or the environment alone.

**[LangSmith](/docs/observability/installation/langsmith)**

OTLP from the environment, as protobuf.

**[LangWatch](/docs/observability/installation/langwatch)**

Its own exporter, with the AI SDK's spans.

**[New Relic](/docs/observability/installation/new-relic)**

OTLP from the environment, as protobuf.

**[PostHog](/docs/observability/installation/posthog)**

OTLP from the environment, or its exporter.

**[Sentry](/docs/observability/installation/sentry)**

Sentry's own OpenTelemetry provider.

**[Traceloop](/docs/observability/installation/traceloop)**

OTLP from the environment, as protobuf.

**[Vercel](/docs/observability/installation/vercel)**

The provider `@vercel/otel` registers.

**[W&B Weave](/docs/observability/installation/weave)**

OTLP from the environment, as protobuf only.

## Already set up?

| I want to… | Read |
|---|---|
| See every API on one page | [The telemetry APIs](/docs/observability/apis) |
| Send to a second backend | [Collector and troubleshooting](/docs/observability/collector) |
| Keep a share of turns | [Sampling](/docs/observability/sampling) |
| Group a conversation in my backend | [metadataMapping](/docs/observability/metadata-mapping) |
| Record prompts, or ask for consent | [Privacy and redaction](/docs/observability/privacy) |
| Count runs without a backend | [onAgentRun](/docs/observability/on-agent-run) |
| Test the span tree | [Test privacy and telemetry](/docs/testing/privacy-and-telemetry) |
