The telemetry APIs
What you have after installation, one page per API: the server's layer and its options, the relay, the page's observer and the run events.
Installation wires three pieces: the layer on the server, the relay route, and the observer on the page. Each has a page of its own below, in the order you would reach for them, and each opens on the backend you picked during installation wherever a backend changes something. Most apps never need more than the defaults; read on when you want to change where spans go, what they record, or how many turns are kept.
defineObservability
The server’s layer: the chat handler records model steps with it.
Where spans go
The five rules that pick a destination, and the OTEL_* environment.
otlp
One OTLP destination in code: a URL, a protocol, headers.
The relay
/api/telemetry: the page’s spans in, checked and redacted.
relayThrough
The page’s spans when your app has its own provider.
appIntegrations
One chat span per step beside your own @ai-sdk/otel.
observeAgents
The page’s runs and tool calls as spans.
onAgentRun
The run events for your own analytics, no backend.
Custom events
Your own events and spans in the run’s trace, page and server.
Sampling
Keep a share of turns, or decide per turn.
metadataMapping
Group a conversation in your backend.
Privacy and redaction
What a span records, and how to record more.
Span names and types
Every span and attribute name as a constant, and the option types.
Collector and troubleshooting
Several backends at once, and spans that do not arrive.
Where each one lives
@webmcp-agents/telemetry/server:defineObservability,otlp, and the layer’srelay,eventandspan. Server only.@webmcp-agents/telemetry:observeAgents,consoleExporter,recordAgentEventandwithAgentSpan, for the page.@webmcp-agents/telemetry/react:<ObserveAgents>, the same observer as a component.@webmcp-agents/chat:onAgentRun, the run events both sides are built on.