Compare error rates between staging and prod

Diff fingerprints between staging and production. Find what's already breaking in staging that the next deploy will carry into prod.

Updated · published

markdown for agents →

difficulty beginner · time to value 1 minute · execution on demand

Start from this

Compare error rates in staging vs production over the last 24 hours. Are there fingerprints staging is hitting that prod hasn't seen yet?

Why this matters

Staging exists to catch bugs before they hit prod. In practice, nobody looks at staging error rates — staging is “where my own stuff runs,” not “the canary.”

Sentry treats staging and prod as separate projects, which means side-by-side comparison is a Sunday-night SQL session. Datadog can chart both, but the question “which fingerprints exist in staging that don’t exist in prod yet?” needs a join nobody writes.

Agentry stores both environments in the same project with environment as a tag. One prompt diffs the fingerprint sets and tells you the new bugs riding on the next train to prod. Catch them on Friday afternoon, ship the fix in the same deploy.

What you get

  • A list of fingerprints present in staging only (= queued for prod)
  • A list of fingerprints 10x worse in staging than prod (= getting worse on the new branch)
  • For each, a one-line interpretation + which deploy introduced it

Walk through it

You

Compare error rates in staging vs production over the last 24 hours. Are there fingerprints staging is hitting that prod hasn’t seen yet?

Agent

Let me pull open cases per environment and diff the fingerprint sets.

Endpoint: GET /v1/projects/:project_id/cases
Exact shape: /v1/openapi.json?path=%2Fv1%2Fprojects%2F%7Bproject_id%7D%2Fcases&method=get
Use query parameters, not a JSON body.
Query/filter concept:
  status: "open",
  since: "24h",
  group_by: "environment"
{
  "by_environment": {
    "production": [
      { "fingerprint": "f_72ac", "event_count": 412, "users_affected": 88 },
      { "fingerprint": "f_91dd", "event_count": 89,  "users_affected": 14 }
    ],
    "staging": [
      { "fingerprint": "f_72ac", "event_count": 18,  "users_affected": 3 },
      { "fingerprint": "f_91dd", "event_count": 4,   "users_affected": 2 },
      { "fingerprint": "f_b32e", "event_count": 71,  "users_affected": 6 },
      { "fingerprint": "f_5c10", "event_count": 22,  "users_affected": 4 }
    ]
  }
}
Agent

Two fingerprints exist in staging that prod has never seen: f_b32e and f_5c10. Both showed up in the last 24h. Let me pull the details.

Endpoint: GET /v1/cases/:case_id
Exact shape: /v1/openapi.json?path=%2Fv1%2Fcases%2F%7Bcase_id%7D&method=get
Use query parameters, not a JSON body.
{
  "id": "f_b32e",
  "error_type": "TypeError",
  "message": "Cannot read properties of null (reading 'workspaceId')",
  "stack_top": "src/api/billing/seats.ts:74",
  "environment": "staging",
  "first_seen_at": 1747280000,
  "deploy_sha_at_first_seen": "9c3a210"
}
Agent

f_b32e is a null-deref in billing/seats.ts:74 reading workspace.workspaceId. First fired 14h ago, right after staging deploy 9c3a210. That deploy isn’t in prod yet — but it’s queued. If you ship today’s PR, this regression goes live.

f_5c10 is a 500 from /api/integrations/slack. Looks like a missing env var on staging only — less urgent but worth checking the deploy doc.

Want me to draft a PR-comment summary so the merger sees this before they push?

The output

Environment diff (staging vs production, last 24h)

In STAGING only (= riding the next deploy to prod):

   71 events / 6 users    TypeError: Cannot read properties of null
                          src/api/billing/seats.ts:74 (workspace.workspaceId)
                          ↗ introduced by staging deploy 9c3a210 — 14h ago

   22 events / 4 users    500 /api/integrations/slack
                          Missing SLACK_SIGNING_SECRET in staging env
                          ↗ probably env-only; unlikely to repro in prod

Worse in STAGING than PROD (10x+):
   (none this window)

In PROD only (= broken right now, fix separately):

  412 events / 88 users   TypeError: Cannot read properties of undefined ('id')
                          src/middleware/auth.ts:42
                          ↗ existing case, see f_72ac

Setting it up

This only works if both environments send errors to the same project and tag the environment field. The hard split (separate Sentry projects per env) is the wrong design for diffing — keep them together.

// Agentry.ts — the small fetch helper your agent generates at install time.
const SERVER_KEY = process.env.AGENTRY_SERVER_API_KEY!;

export async function logError(err: Error, ctx?: Record<string, unknown>) {
  await fetch("https://api.agentry.sh/v1/logs/", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${SERVER_KEY}`,
      "Content-Type": "application/json",
      "User-Agent": "myapp/1.0",  // REQUIRED — Cloudflare 403s default UAs
    },
    body: JSON.stringify({
      message: err.message,
      stack: err.stack,
      environment: process.env.NODE_ENV ?? "production",  // ← THIS LINE
      release: process.env.AGENTRY_DEPLOY_SHA,
      ...ctx,
    }),
  });
}

Create separate server_ingest credentials for staging and production, bind both to the same project, and store each as AGENTRY_SERVER_API_KEY only in its own environment. The environment field drives the comparison while separate credentials preserve independent revocation and provenance.

Variations

  • “Same diff but for the last 7 days — anything chronic in staging that we keep forgetting to fix before promoting?”
  • “Compare staging vs prod error rates by endpoint — which routes are flakier in staging?”
  • “Show fingerprints that appear in staging, then 1-2 deploys later appear in prod. What’s our staging-as-canary precision?”
  • “On demand, summarize staging-only fingerprints for an engineer to review and optionally share with #eng-staging.”

Adapt this workflow in your own agent.

Ask your agent to map the starter prompt to your saved signal map, live events, and the current HTTP API before answering.

Agentry gives coding agents production context from errors, product analytics, and deploys through one HTTP API. Fetch and read https://agentry.sh/install.md completely, then install Agentry's full first-time telemetry baseline in this repository. I authorize device-code login, saving the owner key only to ~/.agentry/credentials.json, creating one Agentry project for this repository, and read-only inspection of shipped source plus hidden CI/provider configuration. Deeply analyze the product's business logic and complete value flow before choosing telemetry. Save the complete source-backed plan and show me its exact contents and hash. Until I explicitly approve that plan or request a replacement, do not edit app/CI source, place runtime/CI credentials, commit, exercise product traffic, start proof, push, or deploy. After approval, I authorize only the reviewed targets: place the required scoped browser/server/CI credentials through the established environment or secret mechanism, preserve existing telemetry, implement and test the baseline, commit it, push that reviewed commit when the shipped CI/provider path requires it, exercise safe proof paths with test/non-customer data, and perform one deployment through the reviewed shipped CI/provider path. Ask first if proof would charge money, contact a third party, change real customer data, or require new external access. After the plan is saved, immediately before every onboarding state-changing POST, GET current onboarding state, perform only its single returned next_action, then read state again; do not batch or infer later stages. Continue until status is verified, installation_complete is true, and next_action is null. Keep all secrets, source snapshots, proof markers, and scratch files outside the repository.

+ Full access
5.5 Extra High
  1. 1. Open your repo in Codex, Claude Code, Cursor etc.
  2. 2. Paste the install prompt.
  3. 3. Your agent reads the install doc and shows you an implementation plan for approval.