Sentry · 2026-11-05 · Primary X Article: Five things you can do with Sentry’s Agent Tracing (Companion Sentry Post) · Frozen Technical Corpus: Agent Tracing Concepts Docs · Debugging Our AI Search Assistant (Dominik Buszowiecki & Shaun Kaasten, 2026-09-11) · Official Sentry Cookbooks (Eval Export / Daily Triage / Spend Attribution & Alerts / OpenTelemetry Forwarding)

Production AI agents rarely fail by throwing an uncaught exception and returning HTTP 500. A tool call can receive an invalid parameter and silently return empty data while the model hallucinates a fluent reply, or a triage agent can drop an order number when delegating to a billing sub-agent without tripping a single error monitor. The practical contribution across Sentry’s five Agent Tracing workflows is pushing telemetry past passive dashboards: converting production traces into offline evaluation datasets, scheduling daily triage that inspects successful runs too, attributing token and dollar spikes down to individual model calls and tool loops, and adding Sentry to existing OpenTelemetry pipelines without ripping out instrumentation.

Evidence & Attribution Scope: Rewritten from Sentry’s November 5, 2026 X Article (curated November 6, 2026) and four frozen primary documents (Agent Tracing docs, the Search Query Assistant blog post, the Conversations-to-Evals cookbook, and the Claude Routines Triage cookbook), cross-checked against Sentry’s companion cookbooks for Next.js cost tracking, spend alerts, and @vercel/otel OTLP forwarding. Taken together, these sources represent qualitative practitioner workflows, SDK/CLI recipes, and one internal debugging case study—with zero controlled comparative benchmarks, zero measured MTTR/MTTA deltas, zero triage precision/recall or false-suppression evaluations, and zero SDK runtime overhead benchmarks. Every number appearing in the corpus must stay scoped to its original context: 340 tokens, $0.002, 800ms, 42ms, 75% latency, and 10x cost spikes in the docs are pedagogical illustrations; the triage cookbook’s Seer example (~445–551 24h conversations, ~11k tool calls, 83/400 or ~21% hitting mostly self-corrected tool errors, and 2 runs hanging 30–56s before "internal error") and FAQ (400–800 conversations scanned, "a few dozen" sampled) are recipe sample outputs and practitioner heuristics; and the Search Query Assistant post is a qualitative root-cause walkthrough (its footer also mentions a coding agent using Sentry MCP to find fixes removing "hundreds of millions of queries a week", though that teaser includes no evaluation methodology in the frozen capture).

Span Hierarchy and Conversation Modeling: Why Flat LLM Monitoring Misses Silent Failures

Before connecting downstream workflows, Sentry’s Agent Tracing documentation separates flat LLM monitoring from hierarchical agent tracing. Traditional LLM monitoring logs an isolated list of single model requests (prompt, completion, tokens, latency, cost, model version)—useful for catching a broken prompt or slow provider response, yet blind to control flow. Agent tracing embeds every agent run (the execution lifecycle from a user turn to final confirmation) inside Sentry’s distributed tracing waterfall so AI spans sit beside HTTP routes, database queries, and queue operations in the same end-to-end trace.

Within that tree, Sentry aligns with OpenTelemetry gen_ai.* semantic conventions around four structural primitives:

  • gen_ai.invoke_agent (Run Container): Wraps an agent execution or turn (named in Vercel AI SDK calls via telemetry: { functionId: 'chat-agent' }, or experimental_telemetry on AI SDK 6 and earlier), aggregating child model and tool telemetry.
  • gen_ai.chat / ai_client (Model Call Span): Captures the model version, prompt inputs, outputs, token counts, estimated cost, and duration (illustrated in docs as sonnet-5, 340 tokens, $0.002, 800ms), revealing exactly what context reached the model.
  • gen_ai.execute_tool (Tool Call Span): Records the invoked function name, serialized arguments, returned payload, and execution time (illustrated as read_file on test_auth.py in 42ms). This span catches two classic failure modes invisible to exception alerts: silent tool failures (passing a malformed customer ID that returns empty results without erroring, prompting the model to hallucinate or claim no orders exist) and nested backend latency (a billing check accounting for 75% of total run time due to a slow db.query span nested underneath the tool call).
  • Agent Handoffs and gen_ai.conversation.id: Dedicated handoff spans capture context delegation across sub-agents (such as a triage agent forwarding a billing inquiry without preserving the user’s order number). Equally important is separating per-request traces from multi-turn conversations: each chat request generates its own distributed trace, so route handlers must call Sentry.setConversationId(conversationId) (for example, reusing the id threaded by Vercel AI SDK’s useChat) to stamp every AI span with gen_ai.conversation.id. As Sentry’s docs emphasize, a conversation need not share one trace, and multiple conversations can exist inside one trace—request-level traces alone cannot reconstruct cross-turn identity.
Sentry Agent Tracing conversation linkage and span hierarchy diagram: top row contrasts flat LLM monitoring blind spots against hierarchical agent tracing; left main container shows gen_ai.conversation.id stitching multi-request distributed traces with Trace #1 nesting gen_ai.invoke_agent, gen_ai.chat, gen_ai.execute_tool, http.client/db.query, and Agent Handoff spans; right panels cover the Search Query Assistant case study and JS SDK v11+ default I/O recording vs privacy opt-out coverage effects; bottom bar states pedagogical example boundaries.Click to zoom ↗
Assistant diagram (not an original figure): Mapping Sentry's two-level conversation-to-trace model, nested span types, Search Query Assistant case study, and privacy coverage gate.

Sentry engineers Dominik Buszowiecki and Shaun Kaasten (September 11, 2026) document how this unified trace hierarchy worked on an internal bug in Sentry’s own Search Query Assistant, which translates natural language into Sentry Search Syntax. End-to-end tests showed zero results whenever users queried custom numerical attributes (such as shopping-cart item counts above 10). Instead of inspecting disconnected JSON blobs, the team filtered Explore → Agents by time window, agent (traces), and developer email, reviewed the AI Conversation timeline, and clicked directly from the tool call into the backend API trace. The root cause sat in how tool results were formatted into the system prompt: available fields were injected by bare name (bug__predictions_count) instead of the typed syntax required by Sentry Search Syntax (tags[bug_predictions_count, number]). Crucially, the team then added a regression scenario and instrumented local eval runs to emit traces to Sentry before opening a pull request, verifying prompt assembly and API parameters in the same production-style timeline before shipping.

One subtle privacy detail spans the docs and cookbooks and directly impacts downstream dataset completeness. While the general Agent Tracing overview describes prompt and output capture as sensitive opt-in fields (recordInputs, recordOutputs), the Next.js Eval Cookbook explicitly clarifies that Sentry JavaScript SDK v11+ enables vercelAIIntegration and records inputs and outputs by default whenever tracesSampleRate > 0. Turning recording off globally via dataCollection: { genAI: { inputs: false, outputs: false } } in Sentry.init(), opting out on sensitive routes via telemetry: { recordInputs: false, recordOutputs: false }, applying server-side PII scrubbing, or lowering tracesSampleRate does more than hide UI text—it produces null firstInput/lastOutput fields or missing conversations, directly shaping what later eval exports can cover.

Workflows 1 & 2: Production-to-Eval Pipelines and Why Daily Triage Must Sample “Successful” Runs

Once gen_ai.conversation.id and input/output telemetry are flowing, Sentry’s first two workflows turn traces into offline regression datasets and daily automated incident triage.

Workflow 1 (Extract → Map → Load): Turning production conversations into eval datasets. In the Conversations-to-Evals Cookbook (targeting Next.js, Vercel AI SDK 7, Node.js 22+, @sentry/nextjs >= 11, and Sentry CLI >= 0.44), the pipeline separates cleanly into three stages:

  1. Extract: Run sentry agent-conversation list YOUR_ORG --period 30d --limit 1000 --json --fields ... (overriding the default 7d window and 25-row limit). Two operational pitfalls govern extraction: use the CLI instead of the MCP server for bulk exports, because MCP truncates payloads to protect agent context windows; and never sum raw spans yourself, because gen_ai.invoke_agent parent spans already aggregate child metrics, so naive summation double-counts tokens and cost. When per-turn models or intermediate tool sequences are needed, run sentry agent-conversation view YOUR_ORG/CONVERSATION_ID --json.
  2. Map: Drop rows where firstInput or lastOutput is null (routes with recording disabled), filter out seeded demos and smoke tests (id.startsWith('test-')), and sort descending by totalTokens so thrashing, loop-heavy runs surface at the top of the dataset.
  3. Load & Score: Upsert records keyed by conversationId into Braintrust (dataset.insert({ id })), Langfuse (langfuse.dataset.createItem()), promptfoo (local JSON + npx promptfoo eval), or Arize Phoenix (client.datasets.create_dataset()), storing lastOutput inside metadata.production_output. Run the first evaluation with a passthrough task (hooks.metadata.production_output) to grade what the agent actually shipped in production before testing candidate models or prompts.

The cookbook pairs that pipeline with strict evaluation guardrails. Use deterministic code wherever verification is objective: database entity lookups (citationsExistInDb), telemetry token efficiency (Math.min(1, 15_000 / total_tokens)), and tool success rates (1 - tool_errors / tool_calls) belong in code, reserving LLM-as-a-judge strictly for subjective helpfulness—calibrated against human labels and self-tested with planted hallucinations so silent scorer regressions fail loudly. Equally vital, production outputs are the subject under test, not automatic ground truth: promote production_output to an expected golden label only after deterministic checks pass, and remember that compressing multi-turn chats into firstInput + lastOutput drops mid-session constraints and can capture an intermediate message if a long run aborted partway through.

Workflow 2 (Claude Routines + Sentry MCP): Daily automated triage that samples “clean” runs too. In the Automated Triage Cookbook, a scheduled Claude Routine (transferable to any cron job or GitHub Action invoking an LLM) connects to the Sentry MCP and Linear MCP (or an equivalent tracker) each morning to inspect the prior 24 hours of conversations. Rather than merely summarizing exception stacks, the prompt instructs the assistant to pull aggregate statistics first, then sample both errored and apparently successful conversations (typically scanning 400–800 conversations at aggregate level and reading "a few dozen" detailed transcripts sorted by tool calls or tokens), searching Linear before creating new tickets to avoid duplicates. It targets six failure classes: tool call failures, hallucinated arguments, latency anomalies (long hangs signaling backend trouble), agent loops, cost anomalies, and reasoning failures—conversations that finished with zero tool errors yet reached a conclusion contradicted by their trace.

The cookbook’s sample triage report on Sentry’s internal Seer assistant shows why inspecting “clean” runs changes operational visibility: across ~445–551 24-hour conversations (~11k tool calls), spot-checked verdicts were sound, yet 83/400 sampled runs (~21%) hit at least one tool error, mostly masked by self-correcting retries—such as passing a monorepo subpath to Search Code ("foo/bar/applications/integrations" instead of "foo/bar") or guessing a project_slug ("mobile") before retrying—while 2 runs hung for 30–56s before failing with an opaque "internal error". None of those inefficiencies show up when teams triage unhandled crashes alone.

Workflow Core Mechanism & SDK / CLI / MCP Interface Prerequisites & Key Failure Traps Downstream Consumer & Output
1. Production Conversations to Evals CLI >= 0.44 (sentry agent-conversation list --json / view --json) in Extract → Map → Load pipeline Default export is 7d / 25 rows; MCP truncates bulk text; summing invoke_agent spans double-counts; firstInput/lastOutput loses mid-turn edits Braintrust, Langfuse, promptfoo, Arize Phoenix; passthrough scoring of production_output with deterministic-first checks
2. Daily Automated Triage Scheduled Claude Routine (or cron/CI LLM loop) using Sentry MCP (stats + sample reads) & Linear MCP (dedup) Error-only filtering misses 0-error reasoning failures, silent retry loops (e.g. Seer 83/400), and pre-error hangs; avoid brittle hardcoded MCP queries Morning engineering digest + deduplicated tracker issues linked to failing or thrashing conversations
3. Per-Call Cost Attribution @sentry/nextjs v11+ auto-enables vercelAIIntegration with setConversationId() & telemetry.functionId Costs are token-based estimates affected by sampling, missing fields & pricing tiers—diagnostic clues, not exact billing reconciliation Explore → Agents dashboards & waterfalls pinpointing 10x run spikes caused by retries or giant tool outputs
4. Spend Dashboard & Hourly Alerts Sentry CLI builds shared LLM Spend per User dashboard (8 widgets) + 2 hourly alerts (static + anomaly) Queries must filter gen_ai.operation.type:ai_client leaf spans or parent agent spans double-count spend; alerts cannot isolate root cause alone Hourly Slack/webhook budget guardrails that route responders back to conversation traces to separate growth from loops
5. Non-Invasive OTel Forwarding @ai-sdk/otel + OTLP HTTP exporter; enableOpenTelemetrySetup: false + openTelemetryIntegration() + getOtlpTracesEndpoint Leaving Sentry’s OTel setup or tracesSampleRate active conflicts with @vercel/otel TracerProvider Standard gen_ai.* spans co-located with existing HTTP/DB spans, unlocking Workflows 1–4 without re-instrumenting

Workflows 3, 4 & 5: Cost Attribution, Dual Spend Alerts, and Non-Invasive OpenTelemetry Ingestion

While the first two workflows route agent traces into testing and daily triage, Workflows 3–5 connect the same span model to unit-economics attribution, hourly anomaly guardrails, and existing OpenTelemetry pipelines.

Workflow 3 (Per-call and per-conversation cost attribution): track-vercel-ai-sdk-costs-and-llm-calls shows how enabling @sentry/nextjs v11+ tracing captures cost without manual dollar instrumentation. Sentry inspects input, cached-input, output, and reasoning token counts per model span, computes estimated costs, and surfaces them by model, agent (Explore → Agents), and conversation. When an agent run that normally costs a few cents jumps 10x (the docs’ illustrative scenario), trace navigation immediately exposes whether one step invoked an expensive model repeatedly or a tool returned a massive text payload forcing repeated context reprocessing. At the same time, Sentry explicitly scopes these numbers: cost figures are diagnostic estimates, not guaranteed reconciliations against provider invoices, because tracesSampleRate, missing usage metadata, and custom pricing or cache-discount rules all introduce variance.

Workflow 4 (Spend dashboards and hourly dual-mode alerts): monitor-ai-agent-spend-dashboards-alerts uses the authenticated Sentry CLI to provision a shared “LLM Spend per User” dashboard with 8 widgets (cost breakdown, token types, top spenders, and per-model totals) alongside 2 hourly alerts: a static threshold alert for hard hourly caps and an anomaly detector flagging statistical deviations from historical baselines. Crucially, the dashboard filters strictly on gen_ai.operation.type:ai_client (alongside gen_ai.usage.total_tokens, gen_ai.response.model, and optional user.id / gen_ai.conversation.id) so parent gen_ai.invoke_agent spans are never double-counted alongside leaf LLM calls. Even then, an hourly spend anomaly signals only that cost shifted—it cannot by itself distinguish organic traffic growth, a model upgrade, a prompt-cache hit-rate drop, or a runaway tool loop without drilling back into conversation counts and tool-call volumes.

Workflow 5 (Non-invasive OTLP forwarding with @vercel/otel): vercel-ai-sdk-opentelemetry enables Next.js or Vercel applications already running @vercel/otel (or a custom NodeSDK) to adopt Sentry without re-platforming existing instrumentation:

  1. Install @ai-sdk/otel, @opentelemetry/exporter-trace-otlp-http, and @opentelemetry/sdk-trace-base.
  2. In sentry.server.config.ts, initialize Sentry with enableOpenTelemetrySetup: false, leave tracesSampleRate unset (so @vercel/otel keeps sole ownership of the tracer provider and avoids duplicate tracking), and include Sentry.openTelemetryIntegration() so errors, logs, and metrics still bind to active OTel spans.
  3. In instrumentation.ts, fetch Sentry.getOtlpTracesEndpoint(process.env.SENTRY_DSN) and pass its url and headers into OTLPTraceExporter + BatchSpanProcessor inside registerOTel(...).

Standard gen_ai.* spans then land beside existing application and database spans inside Sentry’s distributed traces, unlocking the Agents view, CLI eval exports, and MCP triage while preserving vendor-neutral OTel collection.

Overview diagram of all five Sentry Agent Tracing workflows: top row connects native @sentry/nextjs SDK and Workflow 5 @vercel/otel OTLP forwarding as the shared span spine; middle columns detail CLI conversation-to-eval exports, Claude Routine daily triage with clean-run sampling, per-call cost attribution, and the 8-widget spend dashboard with hourly static and anomaly alerts alongside their key pitfalls; bottom panel separates missing empirical metrics, illustrative/local sample figures, and operational causality rules.Click to zoom ↗
Assistant diagram (not an original figure): Connecting Sentry's five Agent Tracing workflows over a shared span spine with per-recipe traps and evidence boundaries.

Evidence Boundaries, Architectural Trade-offs, and Deployment Checklist

Across these sources, Sentry delivers a cohesive set of practitioner patterns rather than controlled experimental evaluations. Keeping documented mechanisms, illustrative snippets, and missing empirical evidence visibly separated prevents teams from treating workflow automation as proven reliability gains:

Claim or Number in Corpus Exact Frozen Source & Context What It Actually Establishes What Remains Unverified
sonnet-5 340 tokens / $0.002 / 800ms; read_file 42ms; 75% latency; 10x run spike Agent Tracing Concepts Docs Pedagogical illustrations showing how model, tool, nested DB, and spend spans diagnose failures Zero measurement of real production latency distributions, attribution error margins, or cost savings
Search Query Assistant tags[bug_predictions_count, number] prompt bug Search Query Assistant Blog (2026-09-11) Qualitative internal case study showing conversation-to-API-trace jumps and local-eval tracing resolve formatting bugs No controlled debugging-time delta; footer teaser claiming MCP fixes saved "hundreds of millions of queries a week" lacks study details here
Seer sample (~445–551 runs / ~11k tools / 83/400 or ~21% retries / 2 30–56s hangs) Automated Triage Cookbook (sample output & FAQ) Shows how sampling successful runs surfaces hidden repo_name/project_slug retry waste and backend hangs; typical 400–800 scan scale Recipe illustration & FAQ heuristics only; no measured triage recall, precision, false-ticket rate, or staff-hours saved
Export --limit 1000, default 25 / 7d, TOKEN_BUDGET = 15_000, 8 widgets & 2 alerts Eval Export & Spend Alert Cookbooks Exact CLI defaults, sample script budget constants, and provisioned dashboard/alert structure Not universal tuning constants; no comparative benchmark across Braintrust, Langfuse, promptfoo, or Phoenix
“Real traffic becomes your ground-truth test set” Eval Cookbook hero summary vs. step-by-step guidance Body explicitly corrects the shorthand: production output is the response under test, promoted to expected only after deterministic checks Unchecked promotion of lastOutput directly into golden test rows would bake production hallucinations into future evals

From an engineering design perspective (assistant derivation from Sentry’s architecture, not a measured vendor claim), three structural trade-offs govern how teams deploy these five workflows:

  • Coupling tracesSampleRate to Eval Coverage and Cost Accuracy: Lowering tracesSampleRate curbs ingestion volume at high QPS, yet Sentry ties incident discovery, per-user spend dashboards, and CLI conversation exports to the same span stream. Naive uniform downsampling distorts hourly budget thresholds and thins out rare silent failures or loop-heavy tail runs from eval exports; production teams must monitor actual capture rates and explicitly adjust cost estimates when sampling below 1.0.
  • Default I/O Capture (@sentry/nextjs v11+) vs. Downstream Third-Party Exposure: Recording prompts and completions by default eliminates friction for conversation replays and CLI exports, but sentry agent-conversation list --json and MCP triage move payloads into third-party eval clouds (such as Braintrust) or scheduled LLM triage prompts. Routes handling PII, credentials, or regulated payloads require explicit recordInputs: false / recordOutputs: false overrides, server-side scrubbing, and ID-based filtering before anything leaves Sentry.
  • MCP Interactive Exploration vs. CLI Bulk Extraction: Although Sentry MCP and sentry agent-conversation query the same underlying store, MCP intentionally truncates large payloads to preserve agent context budgets—well suited to aggregate-first daily triage over 400–800 runs with "a few dozen" deep reads, yet unsuitable for building complete eval datasets or sorting un-truncated runs by totalTokens.

For teams adopting or auditing this stack, five ordered checks translate Sentry’s recipes into disciplined AgentOps practice:

  1. Standardize correlation and OTel ownership first: Bind Sentry.setConversationId() and stable telemetry.functionId labels across chat routes—or configure enableOpenTelemetrySetup: false plus Sentry.getOtlpTracesEndpoint on @vercel/otel stacks so no competing tracer providers collide.
  2. Audit privacy opt-outs and sampling skew before exporting: Lock down sensitive routes with recordInputs / recordOutputs opt-outs and server-side scrubbing, and document how sampling affects both firstInput/lastOutput coverage and spend estimates.
  3. Run deterministic-first passthrough evals and trace local evals too: Extract heavy-token runs via Sentry CLI >= 0.44, score actual production_output with DB lookups and telemetry checks before invoking LLM judges (with planted-hallucination self-tests), promote expected labels only after verification, and send local eval traces to Sentry pre-PR.
  4. Aim daily MCP triage at clean-looking high-cost runs: Configure scheduled triage to inspect both errored and error-free conversations sorted by tool calls or tokens, catch self-corrected retry loops and reasoning breaks, and always search existing tracker issues before filing.
  5. Filter spend boards on leaf ai_client spans and cross-check invoices: Build the 8-widget spend dashboard and hourly static/anomaly alerts strictly on gen_ai.operation.type:ai_client to prevent parent invoke_agent double-counting, investigate spikes via conversation traces, and periodically reconcile Sentry’s token estimates against actual vendor bills.

Primary Sources & Official References

AI-Assisted Curation & Archival Note: Rewritten and expanded by the assistant (authoring_source: assistant, translation_source: assistant) from the frozen Sentry concepts docs, Search Query Assistant blog post, and two frozen Sentry cookbooks, alongside verified companion Sentry Cookbook URLs, paired with the Chinese edition (中文笔记). Preserves original id: sentry-agent-tracing-five-things, date: '2026-11-06', permalink, source_url, and published_at metadata while restricting tags to _data/note_tags.yml (observability, agent-reliability, anomaly-detection). No pre-existing official images were included in the frozen capture; both v3-blue diagrams (sentry-agent-span-hierarchy-en.svg, sentry-tracing-five-lessons-en.svg) are assistant-authored visualizations summarizing the primary workflows without inventing comparative benchmarks.