Sentry integration to rate-limit duplicated errors, using redis to sync error count and identify duplications.
Install it from PyPI:
pip install sentry-deduplicate-integration
Add the integration to your sentry_sdk initialization.
import redis
from sentry_deduplicate_integration import SentryDeduplicateIntegration
sentry_sdk.init(
integrations=[
SentryDeduplicateIntegration(redis_factory=redis.Redis),
],
)
The redis_factory
arg is any function returning a redis client.
For simple projects, it is possible to use it without a Redis instance, using fakeredis, which is an in-memory Redis compatible implementation. It will deduplicate only errors in the same thread.
import fakeredis
from sentry_deduplicate_integration import SentryDeduplicateIntegration
sentry_sdk.init(
integrations=[
SentryDeduplicateIntegration(redis_factory=fakeredis.FakeRedis),
],
)
The DedupeIntegration
is installed by default and we expected it to work, but it just avoid
duplications when the same error is triggered twice, works only in the
same process and only the last error is checked for deduplication.