---
title: Privacy and redaction
description: "What a span contains by default (ids, timings, the model, token counts), how to record prompts and tool data, ask the person first, and why redaction always runs last."
sidebar:
  label: "Privacy and redaction"
related:
  - /security/redaction
  - /observability/observe-agents
  - /testing/privacy-and-telemetry
---

Telemetry leaves your app: it is data about the person's conversation, sent to a third party. So the defaults record
as little as is useful, and every value passes through the redactor on its way out. Read this page before you turn on
content recording, and before you ship to people who have to agree to analytics.

By default a span records ids (conversation, run, step, tool call), timings, the agent and the model, token counts, how
each run and tool call ended, error codes, and the page's URL with every query value redacted. It does not record the
person's messages, the model's prompts and answers, tool inputs or tool results.

## Example

Turn content on separately on each side. On the server, `recordInputs` records prompts and tool definitions on the
model spans, and `recordOutputs` the model's answers; `redact` adds your own rules for this layer:

```ts title="lib/observability.ts"
import { defineObservability } from "@webmcp-agents/telemetry/server";

export const observability = defineObservability({
  // Off by default. On, every value is still redacted, last.
  recordInputs: true,
  recordOutputs: false,

  // Your rules, merged over the defaults for this layer only.
  redact: { keys: (defaults) => [...defaults, "loyaltyId"] },
});
```

In the browser, the same two options of `observeAgents` record tool inputs and results on `execute_tool` spans.

## Options

| Prop | Type | Default | Description |
| - | - | - | - |
| `recordInputs?` | `boolean` | `false` | Record prompts and tool definitions on model spans, redacted. The handler's own telemetry.recordInputs wins. |
| `recordOutputs?` | `boolean` | `false` | Record the model's output on model spans, redacted. The handler's own telemetry.recordOutputs wins. |
| `redact?` | `false \| RedactOptions \| Redactor` | `the process's redactor` | Redaction of everything exported, server spans and relayed browser spans. false only for local debugging. |

Every other option is on [defineObservability](/docs/observability/define-observability#options).

## Your backend

<RememberBackend />

**Any other backend**

Nothing differs: what you turn on is recorded, redacted, and exported as is.

**New Relic**

New Relic keeps attribute values up to 4095 characters: with `recordInputs` or `recordOutputs` on, long prompts and
answers are cut there.

**Sentry**

Through Sentry's provider, the layer redacts the attributes it sets before each span exists. Sentry's own
instrumentations, such as its `vercelAIIntegration` (on by default when tracing is on, with its own `recordInputs`
and `recordOutputs`), are Sentry's to configure. Source:
[Vercel AI integration](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/vercelai/).

## Ask the person first

Where you need consent for analytics, gate the page's spans on it. `enabled` is read when each run starts: a run the
person did not agree to produces no span, makes no request, and does not even load the span builder.

```tsx title="components/observe-runs.tsx"
import { ObserveAgents } from "@webmcp-agents/telemetry/react";

import { consent } from "@/lib/consent";

// Render it once, inside <WebAgentsProvider>. Each run the person
// agreed to becomes spans, posted to /api/telemetry.
export function ObserveRuns() {
  return <ObserveAgents enabled={() => consent.analytics} />;
}
```

The server's spans do not know about the page's consent. If the model steps must not be exported either, decide it on
the server with a [custom sampler](/docs/observability/sampling) that reads a consent cookie, or keep the layer off with
`WEB_AGENTS_OTEL_ENABLED=false`.

## Notes

**Redaction runs last, always**

Every attribute is redacted after your span processors, after `metadataMapping`, and before the span filter and
the exporters, with recording on or off. The rules are the page's on the page and the process's on the server
([Redaction](/docs/security/redaction)); `redact` replaces them for this layer. The relay redacts what a page sends a
second time, since it cannot trust the browser. Your own
[custom events and spans](/docs/observability/custom-events) pass through the same redaction and span filter.

**Through an app's own provider**

Through Sentry's or `@vercel/otel`'s provider, the layer cannot own the pipeline. It then redacts every attribute
it sets before the span exists. What the app's own processors or instrumentations add is theirs to handle.

**The app's own AI SDK integrations**

The chat handler's own `telemetry.recordInputs` and `recordOutputs`, when set, win over the layer's. An AI SDK
integration your app registered itself (`registerTelemetry`) still runs on each step but never records content:
it cannot redact, so only this layer's spans carry prompts and answers. When it is the app's own `@ai-sdk/otel`
one, recording into the same provider, it is left out of the chat's calls
([`appIntegrations`](/docs/observability/app-integrations)), so each step is one span, redacted.

:::warning[`redact: false` is for local debugging only]
It sends every value as it is, from the server and from the pages the relay forwards.
:::

## Next

**[Span names and types](/docs/observability/spans)**

Every span and attribute name as a constant, and the option types.

**[Test privacy and telemetry](/docs/testing/privacy-and-telemetry)**

Check the span tree, and that no secret reaches a span.
