In deadline week, a tax-filing web app gets ten times its usual traffic and one bug fires in a loop; how would you sample and cap its error reports?
answer
- decide once per session
- the rate travels with the report
- count repeats, do not send them
- the submit step is never sampled out
- change the rate without a release
basics
~20 sDecide sampling once per session and put the rate on every report; cap each error group per page and send a count of the repeats; keep submit-step errors at full rate; and let the server change the rate without a release.
solid answer
~50 sAt ten times the traffic, sending every report multiplies ingest cost and can exhaust the error service's quota mid-week, the worst moment to go blind. So the page decides once, at session start, whether this session's reports are kept, using a rate the server hands it with the page's configuration, so operations can lower it for the week without shipping code. Each report carries that rate, so dashboards scale counts back. Errors on the submission and payment steps are kept in every session, because each may be a return that failed to file. In the client, each error group gets a small cap per page (the first three in full, then only a counter sent with the next batch), plus a total cap per page, so a bug looping in an animation-frame callback cannot flood the queue, the user's uplink or the beacon budget. A per-group limit at ingest is the second net.
code
json · 8 lines{
"release": "2026.10.06-4f9c2a",
"sessionSampleRate": 0.1,
"alwaysKeepSteps": ["submit", "payment"],
"perGroupPerPage": 3,
"perPageTotal": 30,
"sendRepeatCounts": true
}go deeper
Recall that sampling means sending only some sessions' reports, and that a bug in a loop must not send thousands of identical reports.
Explain per-session sampling, why each report carries its rate, and how a per-group cap with a repeat counter keeps a loop's magnitude without flooding the queue.
Design for the spike: remotely tunable rate, exemptions for submit and payment errors, client caps before a server limit, and the denominator the release decision needs.
Set the budget policy: who may change the rate in deadline week, how ingest cost is split across teams, and which flows are never sampled.
## The problem this week creates A **tax-filing web app** has one brutal week: the days before the filing deadline bring about **ten times** the usual traffic. Two things go wrong for error reporting at once: - **Volume.** If every session sends every error, ingest volume and cost scale with traffic. Error services usually enforce quotas; hitting one on Wednesday means no reports on Thursday and Friday, when a bad release would hurt the most people. - **A looping bug.** One defect inside a loop (an animation-frame callback, a retry timer, a render that throws on every update) fires dozens of times a second in every affected tab. Uncapped, it floods the queue, crowds out every other error, burns the user's CPU and battery building stacks, eats the user's uplink and the limited data the browser will queue on page hide, and drains the shared quota. **Sampling** decides which sessions report at all. **Rate caps** limit how much any one session, page or error group can send. They solve different halves. ## Sampling: per session, recorded, remotely tunable 1. **Decide once per session.** At session start the reporter draws a random number and keeps or drops the whole session. A kept session then has complete context: every error, with its breadcrumbs, in order. Per-report coin flips keep counts but leave stories with holes. 2. **Carry the rate on every report.** A report kept at a rate of 0.2 stands for five. The dashboard multiplies by the inverse; without that, lowering the rate makes the error count drop and looks like a fix. 3. **Serve the rate with the page's configuration.** The page reads it from a small configuration response at boot, so operations can move it from 1.0 to 0.1 for the week without a release, and back afterwards. 4. **Never sample out what decides a filing.** Errors on the submission and payment steps are kept in every session, marked with rate 1.0: each may be a return that failed to file, and support needs to find it when the user calls. 5. **Keep the session counts unsampled or sampled at a known rate.** The error-free session rate a release decision uses needs a denominator; a tiny "session started / ended with or without error" signal costs little. ## Caps in the client | Lever | Where | What it protects | Cost | |---|---|---|---| | Session sampling | client, at session start | ingest cost and quota | rare errors may be unseen in a sampled week | | Per-group cap per page | client | queue, CPU, uplink, page-hide budget | loses detail after the first few copies | | Repeat counter | client | the magnitude of a loop | needs one extra field per batch | | Total cap per page | client | everything above, against many distinct bugs | a very broken page reports partially | | Per-group limit at ingest | server | the shared quota, other teams' issues | only acts after the user's device paid | The per-group cap needs the client to compute a cheap local key (type, message and top frame as raw text) before anything is sent; the server's real fingerprint comes later. The rule: **send the first three reports of a key in full, then only increment a counter**, and send the counts with the next batch. The dashboard still learns that the bug fired four thousand times in one tab, which is often the most useful fact about it. Client caps come first because only they protect the user's device and network. The server limit exists because not every client will behave: older releases, extensions, scripts the team does not control. ## Choosing the numbers A useful heuristic is to hold ingested volume roughly flat: at ten times the traffic, a session rate of 0.1 gives about a normal week's volume, while the always-kept submit and payment errors and the scaled counts keep the picture honest. A small app can sample at 1.0 all year; sampling is a cost and quota decision, not a rule. Rare errors are the price: an error hitting one session in fifty thousand may go unseen in a sampled week, which is why the critical steps are exempt and why a user-initiated "send diagnostics" action, which bypasses sampling for that session, helps support find one person's failed filing. ## What a strong answer names Per-session sampling, the rate on every report, remote control of the rate, exemptions for the steps that decide a filing, client caps with a repeat counter, and a server limit as the second net, with the cost of each stated.
- Why sample whole sessions instead of flipping a coin for each report?A kept session then holds every error and breadcrumb in order, which is what someone debugging a failed filing reads. Per-report sampling keeps the totals right after scaling, but each user's story has gaps, and a bug that only shows as the third error after two others is hard to see. Per-session sampling also makes the error-free session rate easy to compute from the same decision.
- A user calls support saying their return failed to submit in deadline week; how does a sampled pipeline still help?Errors on the submit and payment steps are kept in every session, so the failure is there, and support can find it by the session id the page shows in its error message or puts on the support form. For other cases, a 'send diagnostics' action lets the user opt their current session into full reporting, bypassing the sample.
It works like a help desk during a storm: it logs every call about the same outage but takes a full statement only from the first few callers, and it never puts a caller reporting a failed payment on hold.
- If the error count fell after the sample rate was lowered, the release got better.
- A server-side quota handles a looping bug, so the client needs no cap.
- Drop every repeat of an error after the first, with no count kept.
- Changing the sample rate for deadline week needs a new release.
- Lowering the sample rate leaves rare errors just as visible as before.