Add option to Dramatiq integration to ignore retried errors #4083
pencil
started this conversation in
Features / New Integrations / Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
When using the
DramatiqIntegration
that the Sentry SDK ships with, you will end up getting an event for every error in your task, even if the error is explicitly marked as retry-able and is handled as such by Dramatiq's built-inRetries
middleware. This is usually not desired, as it adds noise for intermittent issues that are well known and handled accordingly.Additionally, due to the Dramatiq integration monkey patching, it is challenging to work around this with a customized middleware.
Workaround
I am sharing my workaround here in hopes that it helps others running into this issue. I would of course much prefer official support for this behavior.
First up, you have to add the
DramatiqIntegration
to your Sentry integrations as you would normally, but you need to undo the aforementioned monkey patching afterwards, to remove the default Sentry middleware:Next, you have to implement a custom middleware that unifies the
Retries
and the official Sentry middleware:Then, add this middleware instead of the
Retries
middelware to you Dramatiq broker viaadd_middleware
orDRAMATIQ_BROKER["MIDDLEWARE"]
if usingdjango-dramatiq
.Proposed solution
Ideally the
DramatiqIntegration
would have an option to achieve this behavior. I'd be open to investigate how this could possibly be implemented in a PR if this is a feature the Sentry team is willing to support. At the very least, I thought it would be helpful to document the problem and the (somewhat ugly) workaround.Beta Was this translation helpful? Give feedback.
All reactions