Skip to content

Instantly share code, notes, and snippets.

@nateberkopec
Created November 21, 2012 22:31
Show Gist options
  • Save nateberkopec/4128288 to your computer and use it in GitHub Desktop.
Save nateberkopec/4128288 to your computer and use it in GitHub Desktop.
# how can I change this middleware to only call Raven.captureException when a message is placed in the retries queue, let's say, for the third time?
module Raven
class Sidekiq
def call(worker, msg, queue)
begin
yield
rescue => ex
Raven.captureException(ex)
raise
end
end
end
end
::Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add ::Raven::Sidekiq
end
end
@nateberkopec
Copy link
Author

Currently, most of the bug-tracking middlewares are really set up to notify the exception tracker on every exception. because of the way sidekiq is made, sometimes sidekiq is a little eager, starts before the database is done, and then works on the first retry. Is there any way to code this middleware so that I notify the exception tracker on the "nth" retry?

@mperham
Copy link

mperham commented Nov 21, 2012

Are you referring to the transactional issue where Sidekiq tries to find data that hasn't committed yet?

@mperham
Copy link

mperham commented Nov 21, 2012

That issue is covered in the FAQ, use an after_commit callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment