Sha256: cec7a29c2d17c88c13f435a7958475d3866b05adb2e44cbafdf935932dc8dd99

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

require 'sidekiq/exception_handler'
require 'getaround_utils/utils/deep_key_value_serializer'

module GetaroundUtils; end
module GetaroundUtils::Patches; end

class GetaroundUtils::Patches::KeyValueSidekiqExceptions
  module ExceptionHandlerLogger
    def kv_formatter
      @kv_formatter ||= GetaroundUtils::Utils::DeepKeyValueSerializer.new
    end

    def call(exception, ctx)
      payload = {}
      payload[:exception] = exception&.class&.name
      payload[:sidekiq] = ctx
      payload[:message] = exception&.message
      payload[:backtrace] = exception&.backtrace&.join("\n")
      Sidekiq.logger.warn(kv_formatter.serialize(payload.compact))
    end
  end

  def self.enable
    Sidekiq::ExceptionHandler::Logger.prepend ExceptionHandlerLogger
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
getaround_utils-0.1.9 lib/getaround_utils/patches/key_value_sidekiq_exceptions.rb