Commit 82e7eda0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'sh-fix-log-error-mapping' into 'master'

Standardize error message field in structured logs

See merge request gitlab-org/gitlab!73196
parents 56c43cc7 400dd57b
......@@ -528,7 +528,9 @@ module Integrations
yield
rescue StandardError => error
@error = error
log_error("Error sending message", client_url: client_url, error: @error.message)
payload = { client_url: client_url }
Gitlab::ExceptionLogFormatter.format!(error, payload)
log_error("Error sending message", payload)
nil
end
......
......@@ -14,13 +14,13 @@ module Ci
sync_coverage_rules
success
rescue StandardError => error
log_error(
payload = {
pipeline: pipeline&.to_param,
error: error.class.name,
message: error.message,
source: "#{__FILE__}:#{__LINE__}",
backtrace: error.backtrace
)
source: "#{__FILE__}:#{__LINE__}"
}
Gitlab::ExceptionLogFormatter.format!(error, payload)
log_error(payload)
error("Failed to update approval rules")
ensure
[:project_rule_vulnerabilities_allowed, :project_rule_scanners, :project_rule_severity_levels, :project_vulnerability_report, :reports].each do |memoization|
......
......@@ -129,6 +129,13 @@ RSpec.describe Ci::SyncReportsToApprovalRulesService, '#execute' do
allow_next_instance_of(Gitlab::Ci::Reports::LicenseScanning::Report) do |instance|
allow(instance).to receive(:violates?).and_raise('heck')
end
expect(Gitlab::AppLogger).to receive(:error).with(
hash_including(pipeline: anything,
'exception.class' => anything,
'exception.message' => anything,
'exception.backtrace' => anything,
source: anything)).and_call_original
end
specify { expect(subject[:status]).to be(:error) }
......
......@@ -972,7 +972,9 @@ RSpec.describe Integrations::Jira do
expect(jira_integration).to receive(:log_error).with(
'Error sending message',
client_url: 'http://jira.example.com',
error: error_message
'exception.class' => anything,
'exception.message' => error_message,
'exception.backtrace' => anything
)
expect(jira_integration.test(nil)).to eq(success: false, result: error_message)
......
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