Spike protection
Pay-as-you-go means a single broken release can cost real money: a retry loop that throws once per request turns into millions of events in an afternoon. Spike protection watches each project's hourly volume and discards data once it climbs far above that project's own normal.
It is on by default for every project and every protected category.
What it protects
| Category | Units it covers |
|---|---|
| Errors & logs | Error events, security reports, log records |
| Tracing | Transactions and their spans |
| Session Replay | Recorded replay segments |
Cron check-ins and uptime checks are never discarded — dropping a check-in would look like a missed job and open a false incident. AI auto-fix runs are started by you, so they can't flood.
How the threshold is calculated
Every hour, each protected project gets a threshold in units per hour, taken as the larger of:
- A minimum. What a project with no history is measured against, and a floor
under everything else. It is the larger of the deployment's configured floor
(
SPIKE_PROTECTION_MIN_EVENTS_PER_HOUR, 10,000 by default) and what three times your remaining wallet credit would buy per hour over 30 days, split across your projects. - A usage-based value. A weighted mean of the past seven days of hourly volume — weighted so the same hour of the day, and the same hour of the same weekday, count for more than an arbitrary hour — multiplied by five times the standard deviation of that week, clamped between 3× and 6×.
A project with steady traffic therefore gets a threshold a few times its normal peak; a spiky project gets a looser one, because its "normal" already varies.
What happens during a spike
- The hour's counter passes the threshold.
- Everything further in that category, that hour, is discarded — it is never stored and never billed.
- The response is
429with Sentry'sX-Sentry-Rate-Limitsheader (…:organization:spike_protection). Official SDKs read that header and stop sending the affected category until the window passes, so your app stops paying the cost of retries too. - A spike is recorded, and any alert rule subscribed to Spike protection activated fires.
The counter resets on the hour, so data starts flowing again by itself. The threshold is recalculated every hour while a spike runs, and discarded volume fades out of the history (counting about 10% after a day, nothing after two) — so a genuine, sustained increase in traffic lifts the threshold over a day or two instead of being capped forever. The spike closes as soon as a completed hour lands back under the threshold, firing Spike protection deactivated.
Turning it on or off
Settings → Spike protection lists every project with a switch per category, the threshold currently in force, and a log of recent spikes for the selected project. Owners and admins can change it; everyone can see it.
Turning protection off for a category keeps counting volume, so the history is already there if you turn it back on.
Alerts
Add an alert rule (Settings → Webhooks & alerts) on Spike protection activated / deactivated and point it at any channel — SMS, email, Telegram, Bale, Mattermost or a webhook. The message names the project, the category, the threshold and how much was discarded.
API
The endpoints mirror Sentry's, so an existing script only has to change host.
# Current state for every project
GET /api/v1/organizations/<org>/spike-protections
# Enable (POST) or disable (DELETE). `projects` takes ids, slugs or ["$all"];
# omit `categories` to cover all of them.
POST /api/v1/organizations/<org>/spike-protections
DELETE /api/v1/organizations/<org>/spike-protections
{"projects": ["my-app"], "categories": ["tracing"]}
# Spike history for one project
GET /api/v1/organizations/<org>/spikes/projects/<project>
# Recent hourly volume + the thresholds projected for the next 24 hours
GET /api/v1/organizations/<org>/spike-projection/projects/<project>
Related
- Wallet & pay-as-you-go — what each discarded unit would have cost.
- Per-project sample rate (Settings → project) is the static counterpart: it drops a fixed fraction of events all the time, spike protection only steps in when volume is abnormal.