2019-11-21 22:06:14 -05:00
|
|
|
# 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-05-22 05:08:09 -04:00
|
|
|
payload.delete('extra.server')
|
|
|
|
|
2019-11-21 22:06:14 -05:00
|
|
|
if exception.backtrace
|
2019-12-27 10:08:16 -05:00
|
|
|
payload['exception.backtrace'] = Gitlab::BacktraceCleaner.clean_backtrace(exception.backtrace)
|
2019-11-21 22:06:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|