-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
# encoding: utf-8 | ||
|
||
PARAM_BLACKLIST = ['backtrace', 'error_backtrace', 'error_message', 'error_class'] | ||
module Rollbar | ||
PARAM_BLACKLIST = ['backtrace', 'error_backtrace', 'error_message', 'error_class'] | ||
|
||
if Sidekiq::VERSION < '3' | ||
module Rollbar | ||
class Sidekiq | ||
def call(worker, msg, queue) | ||
begin | ||
yield | ||
rescue Exception => e | ||
params = msg.reject{ |k| PARAM_BLACKLIST.include?(k) } | ||
scope = { :request => { :params => params } } | ||
class SidekiqErrorHandler | ||
def self.handle(scope, e, params) | ||
params = msg.reject{ |k| PARAM_BLACKLIST.include?(k) } | ||
scope = { :request => { :params => params } } | ||
|
||
Rollbar.scope(scope).error(e) | ||
raise | ||
end | ||
Rollbar.scope(scope).error(e) | ||
end | ||
|
||
def call(worker, msg, queue) | ||
begin | ||
yield | ||
rescue Exception => e | ||
SidekiqErrorHandler.handle(scope, e, params) | ||
raise | ||
end | ||
end | ||
end | ||
end | ||
|
||
Sidekiq.configure_server do |config| | ||
Sidekiq.configure_server do |config| | ||
if Sidekiq::VERSION < '3' | ||
config.server_middleware do |chain| | ||
chain.add Rollbar::Sidekiq | ||
chain.add Rollbar::SidekiqErrorHandlingMiddleware | ||
end | ||
end | ||
else | ||
Sidekiq.configure_server do |config| | ||
else | ||
config.error_handlers << Proc.new do |e, context| | ||
params = context.reject{ |k| PARAM_BLACKLIST.include?(k) } | ||
scope = { :request => { :params => params } } | ||
|
||
Rollbar.scope(scope).error(e) | ||
SidekiqErrorHandler.handle(scope, e, params) | ||
end | ||
end | ||
end |