Commit cbb6e86f authored by Stan Hu's avatar Stan Hu

Clean up project export error logging

Right now when an exception happens, two messages are logged: one with a
basic debug message, and another with the full error backtrace.  We can
clean this up by emitting one error message with a cleaned backtrace as
an array.
parent 2ba3231c
......@@ -56,8 +56,9 @@ module Gitlab
end
def error(error)
log_error(message: error.message, caller: caller[0].dup)
log_debug(backtrace: error.backtrace&.join("\n"))
error_payload = { message: error.message }
error_payload[:error_backtrace] = Gitlab::Profiler.clean_backtrace(error.backtrace) if error.backtrace
log_error(error_payload)
Gitlab::Sentry.track_acceptable_exception(error, extra: log_base_data)
......
......@@ -53,16 +53,17 @@ describe Gitlab::ImportExport::Shared do
subject.error(error)
end
it 'calls the error logger with the full message' do
expect(subject).to receive(:log_error).with(hash_including(message: error.message))
it 'calls the error logger without a backtrace' do
expect(subject).to receive(:log_error).with(message: error.message)
subject.error(error)
end
it 'calls the debug logger with a backtrace' do
error.set_backtrace('backtrace')
it 'calls the error logger with the full message' do
backtrace = caller
allow(error).to receive(:backtrace).and_return(caller)
expect(subject).to receive(:log_debug).with(hash_including(backtrace: 'backtrace'))
expect(subject).to receive(:log_error).with(message: error.message, error_backtrace: Gitlab::Profiler.clean_backtrace(backtrace))
subject.error(error)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment