Tutorial - how to skip Sentry Slack notifications
Sentry is a popular app for tracking software’s errors and inaccuracies. To better monitor the code, crashes or API calls you can set up a chain of incoming Slack notifications. Yet, Sentry and Slack sometimes aren’t that cooperative as they could be. Read on to see how to turn them off.

We’ve been working on integrations of many different warehouse systems with the Shopify platform. All data exchange between them utilizes Sidekiq workers’ background jobs. Generally, we want to be notified about the first occurrence of an error. So most exceptions are caught by Raven and sent to Sentry. However, we faced some exceptions at remote systems, for example, connection issues. Luckily, after some worker retries the problems were solved without any additional actions. In such cases we wanted Sidekiq workers to have silent retries without spamming our Slack channel with Sentry messages.
The bad news is that Sidekiq doesn’t offer access to retry_count param from a worker. Fortunately, Sidekiq offers us developers middleware that allows us to add a functionality which has access to job attributes including retry_count
. Raven allows to specify in config should_capture
where we will add Proc
, where we exclude custom error Sidekiq::SilentRetryError
.
Let’s start with registering our retry middleware.
tsx
We want to delay some specific network/api errors, so let’s define an array that contains some of them.
tsx
In the next step we define a module which we include in our worker. This module will help us identify monitored worker and also allow us to define retry_count _for_sentry
there.
tsx
Our custom error class:
tsx
In our middleware, we rescue errors for which we want to delay Sentry notifications. If worker’s retry_count
is lower than our retry_count_for_sentry
then we have to replace the original exception with a custom one and raise Sidekiq::SilentRetryError
– otherwise we would have to reraise the original one. Without that, Sidekiq treats the job as completed.
tsx
The last thing to do is to define should_capture
for Raven. We can define Proc
which checks if the exception contains Sidekiq::SilentRetryError
.
tsx
Summary
Sentry will be notified after ninth retry of some errors. We wanted to avoid overflooding Sentry/Slack with notifications. Some jobs after some retries are successful and there’s no need to get notifications from the very beginning.
Let’s Create a Great Website Together
We'll shape your web platform the way you win it!
More posts in this category
January 17, 2022 • 16 min read
READ MORELearn more about is seville good place for workationIs Seville a Good Place for a Workation?
One of the members of our crew who decided to work from another place is Beata Twardowska. Some time ago, Beata returned from a month-long workation in Seville, Spain, and she decided to share her experiences with us.
December 03, 2021 • 6 min read
READ MORELearn more about naturaily honored with clutch global awards 2021Naturaily Honored with Clutch Global Awards 2021!
Naturaily has received a 2021 Clutch Global Award! We have been honored as one of the Top 1000 Service Providers in the world.
November 04, 2021 • 6 min read
READ MORELearn more about backend developer interviewFour Years of Freedom. An Interview with our Backend Developer, Karol Karpinski
At Naturaily, employees who have been with us for more than 3 years constitute 40% of the whole crew! One of them is Karol Karpinski, on board for 4 years. Karol started working at Naturaily in October 2017, and we asked him about his impressions so far.