Search code examples
pythondjangocelerysentry

Sentry: rate limit errors sent to prevent depletion of error quota


When an infrastructure incident happens, the application will start to generate thousands of occurrences of the same error. Is it possible to configure some kind of rate limiting or anything like that on the sentry client (or server) to avoid depleting the error quota?

I'm using Python, Django and Celery mostly.


Solution

  • Yes, there are multiple solutions to this common problem. Sentry is an amazing tool, but when there's that annoying bug it can cause quite the issue.

    Sentry has great documentation that covers this problem. There are two solutions I see as a good use case for you:

    1. Rate limiting - This enables you to control the number of incidents Sentry receives per project over a given period of time, thus some redundant events won't be measured and counted against quota.
    2. Spike protection - Maybe the best way to protect your quota is by enabling the spike protection. Sentry measures your average usage and if there's a abnormal number of events coming in a short period of time they will get ignored.

    Rate limiting is a good protection system, but kinda hardcoded. Spike protection is dynamic and adjusts more to your personal needs. Combination of both could provide a great way to preserve your quota until the end of the month.