Commit a07824d2 authored by Stan Hu's avatar Stan Hu

Make error logging fields consistent in failed JIRA requests

The log messages were being dropped because the `error` type was
expected to be an object, not a string. We standardize on the same
format used throughout the Rails code.

Relates to
https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/11507
parent 2688b8ea
......@@ -40,7 +40,12 @@ module Jira
build_service_response(response)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => error
error_message = "Jira request error: #{error.message}"
log_error("Error sending message", client_url: client.options[:site], error: error_message)
log_error("Error sending message", client_url: client.options[:site],
error: {
exception_class: error.class.name,
exception_message: error.message,
exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
})
ServiceResponse.error(message: error_message)
end
......
......@@ -45,6 +45,10 @@ RSpec.describe Jira::Requests::Projects::ListService do
end
it 'returns an error response' do
expect(Gitlab::ProjectServiceLogger).to receive(:error).with(
hash_including(
error: hash_including(:exception_class, :exception_message, :exception_backtrace)))
.and_call_original
expect(subject.error?).to be_truthy
expect(subject.message).to eq('Jira request error: Timeout::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