chore(api): time-boxed tracing to measure the region move

Merged
SA
2mo ago
+17-5

Why

The five Vercel apps now run in pdx1, colocated with Neon in us-west-2. Nothing has measured what that bought — tracing went off in #7273, so the before-numbers have no after.

The before

From the last 30d of spans, while everything still ran in iad1:

routerequestsreads/reqp50 txnp50 db call
POST /api/integrations/google/gmail/push210k11.173445ms71ms
POST /api/integrations/linear/webhook13.6M6.30250ms71ms
GET /api/trpc/[trpc]183M5.84436ms67ms
POST /api/github/webhook24.0M4.65456ms71ms
GET /api/auth/[...all]75.7M1.0175ms68ms
GET /api/desktop/version10.8M1.0072ms66ms

iad1→us-west-2 is ~60–65ms of wire, so a 66–71ms p50 per call is essentially all network. On trpc GET that's ~389ms of a 436ms p50.

(reads/req is a mean against a median duration, so it's directional, not a literal share.)

What this samples

Three routes, one question each:

  • desktop/version — the control. One query, nothing else, so its p50 is the round trip. 72ms before; colocation should put it near 10ms.
  • trpc GET — the volume case, 5.8 queries a request.
  • gmail/push — the worst case, 11.2 queries a request.

~81k spans/day, 0.4% of the ~19M/day that cost 115× quota in September. Every other route returns 0.

Why this is safer than what caused that incident

The September config defaulted to 0.05 across everything, including a 600M-request auth endpoint. This one defaults to 0.

That 0 is also authoritative in a way the old comment correctly warned tracesSampleRate: 0 is not: per Sentry's sampling precedence, a tracesSampler return value overrides an inherited parent decision, whereas tracesSampleRate loses to it. So an incoming sampled trace header can't reopen the firehose.

Time-boxed

Revert once the after-numbers are in. The comment in the file says so.

https://claude.ai/code/session_01Ho5jMfrUs1e65svM8M2Hc6


Summary by cubic

Adds time-boxed Sentry tracing on three API routes to measure the latency impact of moving the Vercel apps into the same region as Neon.

  • Samples desktop/version, trpc GET, and gmail/push at low rates (~81k spans/day total).
  • Every other route returns 0; the sampler's return value overrides inherited parent decisions, so incoming sampled traces can't reopen the firehose.
  • This is temporary—revert once the after-numbers are captured.

Summary by CodeRabbit

  • Monitoring
    • Added selective performance tracing for key API routes.
    • Other API routes remain excluded from performance trace sampling.