Last active
August 29, 2015 14:03
-
-
Save loopj/014b46eb11d826c2870a to your computer and use it in GitHub Desktop.
Send bugsnag error reports asynchronously using resque, sidekiq, etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send Bugsnag error reports asynchronously using Resque | |
# Add this file to config/initializers/bugsnag_resque.rb | |
# A simple resque job | |
class BugsnagResqueJob | |
@queue = "bugsnag" | |
def self.perform(*args) | |
Bugsnag::Notification.deliver_exception_payload_without_resque(*args) | |
end | |
end | |
# Monkey-patch Bugsnag::Notification to use our Resque job | |
Bugsnag::Notification.class_eval do | |
class << self | |
def deliver_exception_payload_with_resque(*args) | |
Resque.enqueue(BugsnagResqueJob, *args) | |
end | |
alias_method :deliver_exception_payload_without_resque, :deliver_exception_payload | |
alias_method :deliver_exception_payload, :deliver_exception_payload_with_resque | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send Bugsnag error reports asynchronously using Sidekiq 3. | |
# Add this file to config/initializers/bugsnag_sidekiq3.rb | |
# A simple sidekiq3 worker | |
class BugsnagSidekiqWorker | |
include Sidekiq::Worker | |
def perform(*args) | |
Bugsnag::Notification.deliver_exception_payload_without_sidekiq(*args) | |
end | |
end | |
# Monkey-patch Bugsnag::Notification to use our Sidekiq worker | |
Bugsnag::Notification.class_eval do | |
class << self | |
def deliver_exception_payload_with_sidekiq(*args) | |
BugsnagSidekiqWorker.perform_async(*args) | |
end | |
alias_method :deliver_exception_payload_without_sidekiq, :deliver_exception_payload | |
alias_method :deliver_exception_payload, :deliver_exception_payload_with_sidekiq | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment