Welcome to mirror list, hosted at ThFree Co, Russian Federation.

exception_handler.rb « sidekiq_logging « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8ae6addc2c625a9d6335ac2d6b235df8540770f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Gitlab
  module SidekiqLogging
    class ExceptionHandler
      def call(job_exception, context)
        data = {
          error_class: job_exception.class.name,
          error_message: job_exception.message
        }

        if context.is_a?(Hash)
          data.merge!(context)
          # correlation_id, jid, and class are available inside the job
          # Hash, so promote these arguments to the root tree so that
          # can be searched alongside other Sidekiq log messages.
          job_data = data.delete(:job)
          data.merge!(job_data) if job_data.present?
        end

        data[:error_backtrace] = Rails.backtrace_cleaner.clean(job_exception.backtrace) if job_exception.backtrace.present?

        Sidekiq.logger.warn(data)
      end
    end
  end
end