stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
305 stars 48 forks source link

Rate limiting certain errors #95

Closed kkmuffme closed 3 years ago

kkmuffme commented 3 years ago

If the WP DB (or Redis,...) goes away, within a few minutes the sentry issue allowance is used up (sending thousands of issues per minute)

Is there a way to rate limit these errors from the plugin's end? (if there is a possibility to do it from sentry's interface that is welcome too)

EDIT: sorry for the edit, I fat fingered on enter

stayallive commented 3 years ago

There are 2 ways, none in the SDK but Sentry itself has 2 very useful features to prevent this:

Technically setting a sample rate in the SDK would also work but I would recommend against it since that might also mean legitimate issues slip through because they are not sampled: https://docs.sentry.io/platforms/php/configuration/options/#sample-rate. Wanted to mention it though, but be careful if you decide to use it.

For extra context see: https://docs.sentry.io/product/accounts/quotas/.

kkmuffme commented 3 years ago

https://docs.sentry.io/product/accounts/quotas/#spike-protection

Works extremely bad. e.g. my issues went from 20000 to 100 000 in 1 day, with just 5 issues. Even though it "spike protected" 25000 events, there are more than 80 000 which it didn't "kick in"

https://docs.sentry.io/product/accounts/quotas/manage-event-stream-guide/#6-rate-limiting

Only works on a more expensive business plan, that is overkill for most WP use cases.

Additionally this will rate limit ALL errors, but I only want to rate limit a specific set of errors (e.g. connection timeout,...)

I built a simple rate limiter now myself, via the wp_sentry_options add_filter