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.
Any OTLP backend
Grafana, Honeycomb, SigNoz, Axiom, Jaeger or your own Collector, from the environment.
Arize
Arize AX or Phoenix, through OpenInference’s span processor.
Braintrust
Its span processor, or the environment alone.
Datadog
The agentless OTLP intake, or the provider of dd-trace.
Helicone
The chat’s model, logged on its way to the provider.
IBM Instana
Agentless, or through the host agent, as protobuf.
Laminar
OTLP from the environment, as JSON or protobuf.
Langfuse
Its span processor, or the environment alone.
LangSmith
OTLP from the environment, as protobuf.
LangWatch
Its own exporter, with the AI SDK’s spans.
New Relic
OTLP from the environment, as protobuf.
PostHog
OTLP from the environment, or its exporter.
Sentry
Sentry’s own OpenTelemetry provider.
Traceloop
OTLP from the environment, as protobuf.
Vercel
The provider @vercel/otel registers.
W&B Weave
OTLP from the environment, as protobuf only.
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 |