Skip to content

feat(sentry): add global, fatal and per-fingerprint rate limits - #312

Open
alankemp wants to merge 1 commit into
cloudflare:mainfrom
alankemp:sentry-rate-limits
Open

alankemp wants to merge 1 commit into
cloudflare:mainfrom
alankemp:sentry-rate-limits

Conversation

@alankemp

Copy link
Copy Markdown

Add global_rate_limit, fatal_rate_limit and per_fingerprint_rate_limit to SentrySettings, each with a configurable burst and period. max_events_per_second remains as a shorthand for a per-fingerprint limit.

Events are checked against the per-fingerprint limit first, then passed to any previous before_send hook, then checked against the shared global or fatal limit, so that events dropped earlier don't use up the shared allowance. Fatal events have their own limit, when enabled, so that a flood of other events can't crowd out panics.

Fingerprints are tracked by hash, up to max_tracked_fingerprints (10,000 by default, 0 for no cap). Beyond the cap, new fingerprints are only subject to the shared limits until idle fingerprints are forgotten.

Dropped events are counted by the new
sentry_events_rate_limited_total{level,limit} metric.

BREAKING CHANGE: SentrySettings has new public fields, so constructing it with a struct literal without ..Default::default() no longer compiles. This requires a 2.0.0 release of foundations-sentry. Existing max_events_per_second users are now also subject to the default 10,000 tracked fingerprint cap.

… limits

Add `global_rate_limit`, `fatal_rate_limit` and `per_fingerprint_rate_limit`
to `SentrySettings`, each with a configurable burst and period.
`max_events_per_second` remains as a shorthand for a per-fingerprint limit.

Events are checked against the per-fingerprint limit first, then passed to
any previous `before_send` hook, then checked against the shared global or
fatal limit, so that events dropped earlier don't use up the shared allowance.
Fatal events have their own limit, when enabled, so that a flood of other
events can't crowd out panics.

Fingerprints are tracked by hash, up to `max_tracked_fingerprints` (10,000 by
default, 0 for no cap). Beyond the cap, new fingerprints are only subject to
the shared limits until idle fingerprints are forgotten.

Dropped events are counted by the new
`sentry_events_rate_limited_total{level,limit}` metric.

BREAKING CHANGE: `SentrySettings` has new public fields, so constructing it
with a struct literal without `..Default::default()` no longer compiles. This
requires a 2.0.0 release of foundations-sentry. Existing
`max_events_per_second` users are now also subject to the default 10,000
tracked fingerprint cap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant