Cut Sentry event volume: sample traces, stop bot URLs causing 500s - #20
Merged
Conversation
The frontend ran tracesSampleRate: 1 on the server, client and edge, so every request became a transaction with a span per Prisma query. Nothing absorbed that traffic: / and /status are force-dynamic and every other page reads searchParams. Sample 1% instead (SENTRY_TRACES_SAMPLE_RATE), drop crawlers via isbot, and drop the tunnel route and static paths via ignoreTransactions. Separately, two unguarded parses turned ordinary bot traffic into unhandled 500s, each one a billed error event: - decodeString called decodeURIComponent on user-controlled path segments, which throws URIError on any malformed percent-escape (/player/%). Used by the player, clan, gametype and map routes. - The [port] param coerced without a fallback, so /server/1.2.3.4/x threw. generateMetadata hit this even though the page already guarded with safeParse. Both now fall back to a value that matches no record, so these 404 rather than throwing. Added app/error.tsx, which reports only client-side errors (server ones already arrive reported, keyed off error.digest), and made the root layout's query degrade to empty tabs, since error.tsx cannot catch root layout errors. Also removed the per-game-server captureMessage in gameServerScheduler: it fired once per server per 5-minute poll, which at ~900 servers is ~10k events an hour for a single global condition already logged once a minute. It was inert only because apps/scheduler/src/sentry.ts is never imported. Replay session sampling goes 0.1 -> 0 (free plan allows ~50/month). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The frontend ran
tracesSampleRate: 1across the server, client and edge configs, so every request became a transaction with a span per Prisma query and nothing absorbed it (/and/statusareforce-dynamic, every other page readssearchParams); it now samples 1% viaSENTRY_TRACES_SAMPLE_RATE, drops crawlers withisbot, and drops the tunnel route and static paths with Sentry'signoreTransactions.Two unguarded parses also turned ordinary bot traffic into unhandled 500s that were each billed as an error event —
decodeStringthrewURIErroron any malformed percent-escape (/player/%, used by the player, clan, gametype and map routes) and the[port]param coerced without a fallback, so both now fall back to a value that matches no record and 404 instead of throwing.Added
app/error.tsx, which reports only client-side errors (server ones already arrive reported, keyed offerror.digest) so nothing is billed twice, and made the root layout's query degrade to empty tabs sinceerror.tsxcannot catch root-layout errors.Removed the per-game-server
captureMessageingameServerScheduler, which fired once per server per 5-minute poll — roughly 10k events an hour at ~900 servers — for a single global condition already logged once a minute.Replay session sampling also drops from 0.1 to 0 against a free-plan allowance of ~50 per month, and
isbotis the only added dependency.🤖 Generated with Claude Code