Sha256: b9dfa5f5e6f75aa71e9db7bf4635328cffd112637ebf0e24e9e4699839df44f5

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 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[:message] = exception.message
      payload[:exception] = exception.class.name
      payload[:backtrace] = exception.backtrace&.join("\n")
      payload[:sidekiq] = ctx
      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.11 lib/getaround_utils/patches/key_value_sidekiq_exceptions.rb