debian-mirror-gitlab/lib/gitlab/exception_log_formatter.rb

31 lines
929 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Gitlab
module ExceptionLogFormatter
def self.format!(exception, payload)
return unless exception
# Elasticsearch/Fluentd don't handle nested structures well.
# Use periods to flatten the fields.
payload.merge!(
'exception.class' => exception.class.name,
'exception.message' => exception.message
)
2020-06-23 00:09:42 +05:30
payload.delete('extra.server')
payload['extra.sidekiq'].tap do |value|
if value.is_a?(Hash) && value.key?('args')
value = value.dup
payload['extra.sidekiq']['args'] = Gitlab::ErrorTracking::Processor::SidekiqProcessor
.loggable_arguments(value['args'], value['class'])
end
end
2019-12-26 22:10:19 +05:30
if exception.backtrace
2020-03-13 15:44:24 +05:30
payload['exception.backtrace'] = Gitlab::BacktraceCleaner.clean_backtrace(exception.backtrace)
2019-12-26 22:10:19 +05:30
end
end
end
end