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

metadataMapping

Group a conversation's traces in your backend: copy webmcp.conversation.id to the key your backend groups by, exported raw.

Every span carries webmcp.conversation.id, so you can always find every turn of one conversation. A backend that groups traces into sessions or threads does it by a key of its own, though, and metadataMapping copies the id to that key. Use it when your backend has a sessions or threads view; skip it when filtering by webmcp.conversation.id is enough.

Example

import { defineObservability } from "@webmcp-agents/telemetry/server";

// Copy the conversation id to the key your backend groups by. The
// copy is exported raw: map ids, never content.
export const observability = defineObservability({
  metadataMapping: { "webmcp.conversation.id": "session.id" },
});

observeAgents takes the same option for the page’s own spans.

Options

PropType
metadataMapping?Record<string, string>

Copy one of the span's attributes to the name a backend groups by. Runs before redaction.

TypeRecord<string, string>

Every other option is on defineObservability.

Your backend

Your backend’s key, which the lib/observability.ts of its installation maps:

Map the id to the key your backend groups by, if it has one. Without one, filter by webmcp.conversation.id itself.

Arize AX and Phoenix both group sessions by session.id, which its setup maps. Source: Phoenix sessions.

Braintrust documents no session or user attribute, so its setup maps nothing: filter by webmcp.conversation.id, which is on every span. Source: Attributes.

LLM Observability builds sessions from gen_ai.conversation.id, which its setup maps. Source: LLM Observability with OpenTelemetry.

Helicone logs model calls, not spans: its sessions come from the model provider’s extraBody: { helicone: { sessionId, userId } }, not from metadataMapping. Source: Sessions.

Its setup maps no key: filter by webmcp.conversation.id, which is on every span.

Laminar groups traces into sessions by lmnr.association.properties.session_id on the root span (and people by …user_id), which its setup maps. Source: Span attribute reference.

Langfuse groups traces into sessions by langfuse.session.id (or session.id), and people by langfuse.user.id (or user.id). Its setup maps the conversation id to the session. Source: OpenTelemetry integration.

LangSmith groups traces into threads by langsmith.trace.session_id, which its setup maps. Sources: Trace with OpenTelemetry, Threads.

LangWatch groups messages into threads by langwatch.thread.id (and people by langwatch.user.id), as in its setup’s metadataMapping. Source: Semantic conventions.

Its setup maps no key: filter by webmcp.conversation.id, which is on every span.

PostHog takes its session from $ai_session_id, or else from gen_ai.conversation.id, which its setup maps. The person is posthog.distinct_id (or user.id): set it from your own user id where you have one. Source: OpenTelemetry installation.

Sentry groups AI spans into conversations by gen_ai.conversation.id, which its setup maps. Set the person with Sentry.setUser. Source: AI conversations.

Traceloop filters by association properties, any key under traceloop.association.properties.; its setup maps the conversation id to traceloop.association.properties.conversation_id. Source: Association properties.

Vercel forwards traces to the backend of your choice through its Trace Drains: map the id to that backend’s key.

Weave groups turns into threads by wandb.thread_id, which its setup maps. Source: OpenTelemetry in Weave.

Notes

Next

Was this page helpful?