mirror of
				https://github.com/mperham/sidekiq.git
				synced 2022-11-09 13:52:34 -05:00 
			
		
		
		
	 4a7da4302d
			
		
	
	
		4a7da4302d
		
	
	
	
	
		
			
			Backout previous change to the exception handler signature and instead just log at error level the main part of the redis exception then just use the original exception handler as-is (at warn level) for the backtrace. This is a compromise in compatibility insofar as the backtrace is now at a lower log level, but alerting specifically on these error strings likely uses the main error strings explicitly logged before the very verbose backtrace.
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			825 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			825 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # frozen_string_literal: true
 | |
| require 'sidekiq'
 | |
| 
 | |
| module Sidekiq
 | |
|   module ExceptionHandler
 | |
| 
 | |
|     class Logger
 | |
|       def call(ex, ctxHash)
 | |
|         Sidekiq.logger.warn(Sidekiq.dump_json(ctxHash)) if !ctxHash.empty?
 | |
|         Sidekiq.logger.warn("#{ex.class.name}: #{ex.message}")
 | |
|         Sidekiq.logger.warn(ex.backtrace.join("\n")) unless ex.backtrace.nil?
 | |
|       end
 | |
| 
 | |
|       Sidekiq.error_handlers << Sidekiq::ExceptionHandler::Logger.new
 | |
|     end
 | |
| 
 | |
|     def handle_exception(ex, ctxHash={})
 | |
|       Sidekiq.error_handlers.each do |handler|
 | |
|         begin
 | |
|           handler.call(ex, ctxHash)
 | |
|         rescue => ex
 | |
|           Sidekiq.logger.error "!!! ERROR HANDLER THREW AN ERROR !!!"
 | |
|           Sidekiq.logger.error ex
 | |
|           Sidekiq.logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
 | |
|         end
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |