Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log certain Sidekiq errors only on their final retry #353

Merged
merged 1 commit into from
Sep 21, 2017

Conversation

alecgibson
Copy link
Contributor

@alecgibson alecgibson commented Sep 21, 2017

Some of our Sidekiq errors arise from interactions with 3rd party APIs,
and failures beyond our control are to be expected from time to time.
We do not want to be notified every time we get one of these errors;
we just want to be notified the final time the job fails.

This change updates our ApplicationJob to perform its tasks inside a
block that will be rescued when certain errors raise. It will then
re-raise a RetryableError, which will be ignored by Sentry.

When the retries on a job are exhausted, the error will finally be sent
to Sentry.

Raven is Sentry's API offering. Documentation on the Ruby implementation
can be found here.

We thought about solving this using Raven's should_capture method,
which would enable us to filter errors base on arbitrary conditions,
but that would have require some error parsing. The approach taken here
is more explicit about the expected errors, and requires fewer moving
parts.

@alecgibson
Copy link
Contributor Author

class ApplicationJob
include Sidekiq::Worker

# List of errors to retry without alerting Sentry until their final retry
ERRORS_TO_RETRY_WITHOUT_ALERTS = [
Google::Apis::RateLimitError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include here Google::Apis::RateLimitError. It could have implications in our GA quota.

@@ -0,0 +1,3 @@
Raven.configure do |config|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please write a brief description in the commit notes about what raven is, and where we can find documentation about it?

Some of our Sidekiq errors arise from interactions with 3rd party APIs,
and failures beyond our control are to be expected from time to time.
We do not want to be notified every time we get one of these errors;
we just want to be notified the final time the job fails.

This change updates our `ApplicationJob` to perform its tasks inside a
block that will be rescued when certain errors raise. It will then
re-raise a `RetryableError`, which will be ignored by Sentry.

When the retries on a job are exhausted, the error will finally be sent
to Sentry.

Raven is Sentry's API offering. Documentation on the Ruby implementation
can be found [here][raven].

We thought about solving this using Raven's `should_capture` method,
which would enable us to filter errors base on arbitrary conditions,
but that would have require some error parsing. The approach taken here
is more explicit about the expected errors, and requires fewer moving
parts.

[raven]: https://docs.sentry.io/clients/ruby/
@alecgibson alecgibson force-pushed the log-last-sidekiq-retry branch from 21e8ebf to 81ea954 Compare September 21, 2017 10:12
@alecgibson
Copy link
Contributor Author

@pmanrubia done.

@pmanrubia pmanrubia merged commit 1a1be97 into master Sep 21, 2017
@pmanrubia pmanrubia deleted the log-last-sidekiq-retry branch September 21, 2017 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants