Skip to content

Commit

Permalink
Support Sidekiq 6.5 (#31)
Browse files Browse the repository at this point in the history
* Fix tests to run with Sidekiq 6.5

* Deal with removed Sidekiq::ExceptionHandler::Logger in Sidekiq 6.5

Fixes #30
  • Loading branch information
iMacTia authored Jun 9, 2022
1 parent 6b1523d commit cfc42b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion .ruby-gemset

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

7 changes: 5 additions & 2 deletions lib/sidekiq/logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ def self.configure
def self.setup(_opts = {})
# Calls Sidekiq.configure_server to inject logics
Sidekiq.configure_server do |config|
# Remove default Sidekiq error_handler that logs errors
config.error_handlers.delete_if { |h| h.is_a?(Sidekiq::ExceptionHandler::Logger) }
if defined?(Sidekiq::ExceptionHandler::Logger)
# Remove default Sidekiq error_handler that logs errors
# NOTE: this only exists up until Sidekiq 6.4.x
config.error_handlers.delete_if { |h| h.is_a?(Sidekiq::ExceptionHandler::Logger) }
end

# Add logstash support
config.options[:job_logger] = Sidekiq::LogstashJobLogger
Expand Down
4 changes: 2 additions & 2 deletions spec/sidekiq/logstash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def process(worker, params = [], encrypt: false)
let(:buffer) { StringIO.new }
let(:logger) { Logger.new(buffer) }
let(:job) { build(:job) }
let(:processor_options) { { queues: ['default'] } }
let(:processor) { ::Sidekiq::Processor.new(nil, processor_options) }
let(:processor_options) { Sidekiq }
let(:processor) { ::Sidekiq::Processor.new(processor_options) }
let(:log_message) { JSON.parse(buffer.string) }
let(:log_messages) { buffer.string.split("\n").map { |log| JSON.parse(log) } }

Expand Down

0 comments on commit cfc42b1

Please sign in to comment.