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

Accept three arguments into Sidekiq error handler #495

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- `Honeybadger::Config#respond_to?` would always return true (#490)

### Changed
- Accept three arguments for the Sidekiq error handler (#495)

## [5.2.1] - 2023-03-14
### Fixed
- Remove ANSI escape codes from detailed error message in Ruby 3.2 (#473)
Expand Down
13 changes: 10 additions & 3 deletions lib/honeybadger/plugins/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ def call(_worker, _msg, _queue)
if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
::Sidekiq.configure_server do |sidekiq|

sidekiq.error_handlers << lambda { |ex, sidekiq_params|
sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ?
::Sidekiq.default_configuration : Class.new

sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration|
params = sidekiq_params.dup
if defined?(::Sidekiq::Config) && params[:_config].is_a?(::Sidekiq::Config)
params[:_config] = params[:_config].instance_variable_get(:@options)
if defined?(::Sidekiq::Config)
if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5
params[:_config] = params[:_config].instance_variable_get(:@options)
else # Sidekiq >= 7.1.5
params[:_config] = sidekiq_config.instance_variable_get(:@options)
end
end

job = params[:job] || params
Expand Down
3 changes: 3 additions & 0 deletions spec/unit/honeybadger/plugins/sidekiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
Class.new do
def self.configure_server
end

def self.default_configuration
end
end
end

Expand Down