Skip to content
WebMCP Agents
Esc
↑↓navigate↵open⌘Jpreview
On this page

Trace agent runs

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.

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.

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:

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). The names and attributes are on Span names and types.

How it works

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.

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.

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.

Already set up?

I want to… Read
See every API on one page The telemetry APIs
Send to a second backend Collector and troubleshooting
Keep a share of turns Sampling
Group a conversation in my backend metadataMapping
Record prompts, or ask for consent Privacy and redaction
Count runs without a backend onAgentRun
Test the span tree Test privacy and telemetry

Was this page helpful?