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

notify Sentry about RetryLimitHit only from sidekiq #393

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

vasconsaurus
Copy link
Contributor

@vasconsaurus vasconsaurus commented Sep 21, 2023

Description

We were notifying Sentry both through Media.give_up and through
configuration inside 03_sidekiq. We are keeping only the one in 03_sidekiq.rb.
It’s the most specific error and the right place.

In order to try to get more information, we are replacing
Sentry.capture_exception(ex) by PenderSentry.notify(ex, { job: job })

References: 3706, 3757, 3707

How has this been tested?

I tried writing a test to make sure teh Archiver isn't notifying Sentry anymore:
test "MediaArchiver should not notify Sentry when the worker hits the maximum number of retries"
rails test test/models/archiver_test.rb:746

Things to pay attention to during code review

I ran a bunch of tests to make sure the test is working, but I'm not sure about it: if it makes sense the way it's written, if it's even needed.

We were notifying Sentry both through Media.give_up and through
configuration inside 03_sidekiq. We are keeping only the one in 03_sidekiq.rb.
It’s the most specific error and the right place.

In order to try to get more information, we are replacing
Sentry.capture_exception(ex) by PenderSentry.notify(ex, { job: job })

I also tried writing a test to make sure teh Archiver isn't notifying
Sentry anymore.
@vasconsaurus vasconsaurus marked this pull request as ready for review September 21, 2023 14:18
@@ -12,7 +12,7 @@

config.death_handlers << ->(job, ex) do
if ex.is_a?(Pender::Exception::RetryLater)
ex = Pender::Exception::RetryLimitHit.new(ex)
ex = Pender::Exception::RetryLimitHit.new(ex, {job: job})
Copy link
Contributor

Choose a reason for hiding this comment

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

The exception doesn't take a second argument, it should remain like it was:

ex = Pender::Exception::RetryLimitHit.new(ex)

@@ -12,7 +12,7 @@

config.death_handlers << ->(job, ex) do
if ex.is_a?(Pender::Exception::RetryLater)
ex = Pender::Exception::RetryLimitHit.new(ex)
ex = Pender::Exception::RetryLimitHit.new(ex, {job: job})
end
Sentry.capture_exception(ex)
Copy link
Contributor

Choose a reason for hiding this comment

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

What changes is here. We need to be able to send additional information along with the Sentry notification. I don't know if Sentry.capture_exception does that. If not, I suggest replacing this line by:

PenderSentry.notify(ex, { job: job })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To send the extra information we need to set the scope, we have abstracted that in PenderSentry.notify. So I updated to use it.

The exception doesn't take a second argument.
We need to send the extra intormation to Sentry, that is done through
the scope. Our notify method inside PenderSentry abstracts that for us.
@codeclimate
Copy link

codeclimate bot commented Sep 21, 2023

Code Climate has analyzed commit 5a0da73 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 98.6% (0.0% change).

View more on Code Climate.

Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

Looks good! Good to go once tests pass. The new test looks good too, just one question: is that ensure WebMock.disable! needed? Isn't that handled by the teardown method?

@vasconsaurus
Copy link
Contributor Author

Looks good! Good to go once tests pass. The new test looks good too, just one question: is that ensure WebMock.disable! needed? Isn't that handled by the teardown method?

Not sure. Since the other tests inside this file had it (the ensure WebMock.disable!) I thought it was best to keep it.

In our tests where we don't have the ensure WebMock.disable! we are using the isolated_teardown from test_helper. Which I don't think is the case here.

What do you think?

@caiosba
Copy link
Contributor

caiosba commented Sep 21, 2023

Looks good! Good to go once tests pass. The new test looks good too, just one question: is that ensure WebMock.disable! needed? Isn't that handled by the teardown method?

Not sure. Since the other tests inside this file had it (the ensure WebMock.disable!) I thought it was best to keep it.

In our tests where we don't have the ensure WebMock.disable! we are using the isolated_teardown from test_helper. Which I don't think is the case here.

What do you think?

OK, sounds good to keep it as is for now.

@vasconsaurus vasconsaurus merged commit abacdf1 into develop Sep 21, 2023
4 checks passed
@vasconsaurus vasconsaurus deleted the bug-3706-deduplicate-archiver-error branch September 21, 2023 17:09
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