# Trace production traffic

Add the Zhanla SDK to your app and each request becomes a trajectory: the user's message, every model and tool call, and the reply.

Create an API key in the web app under **Settings → API Keys**, then follow the [Python](https://zhanla.vercel.app/docs/sdk/python) or [TypeScript](https://zhanla.vercel.app/docs/sdk/typescript) guide. A key can be limited to one agent. If your agent already exports OpenTelemetry, it can send to Zhanla without the SDK. Set a session id on every request. Without one, Zhanla can't tell how users reacted to a reply.

When the first trajectories arrive, open Zhanla in the agent's repository and it offers to watch them.

## Watching

While a session is open, every 50 new trajectories for an agent trigger one model pass, at most once a day, looking for behaviour your dataset doesn't cover. Anything it finds shows under **Needs you**, and you can draft dataset items from it.

Production trajectories are read in the terminal, not the web app.

### Python

## What leaves your app, and how long it is kept

For each request: the input and output of each `observe`d call; each model call's model name, messages, reply and token counts; each tool call's name, arguments and result; error messages and stack traces; the session id, user id, tags and metadata you set; the agent id; and span names and timings. Spans that installed frameworks create on their own (for example FastAPI's) are sent too.

To redact data before it leaves the process, pass `mask`:

```python
zhanla.init(agent=…, mask=lambda value: redact_emails(value))
```

`mask` runs on every input, output, message, tool argument and result, and error message. What it returns is what gets sent. It does not run on session ids, user ids, tags, metadata, model names or tool names.

Production trajectories are kept with no automatic deletion at the moment. A trajectory over 5 MB is refused and not stored.

### TypeScript

## What leaves your app, and how long it is kept

For each request: the input and output of each `observe`d call; each model call's model name, messages, reply and token counts; each tool call's name, arguments and result; error messages and stack traces; the session id, user id, tags and metadata you set; the agent id; and span names and timings. Next.js's own spans are not sent.

To redact data before it leaves the process, pass `mask`:

```js
await init({ agent: process.env.ZHANLA_AGENT_ID, mask: (value) => redactEmails(value) });
```

`mask` runs on every input, output, message, tool argument and result, and error message. What it returns is what gets sent. It does not run on session ids, user ids, tags, metadata, model names or tool names.

Production trajectories are kept with no automatic deletion at the moment. A trajectory over 5 MB is refused and not stored.

---

Source: https://zhanla.vercel.app/docs/production/tracing
Updated 2026-11-24. Checked against release candidate b60cdc94.
