Commit 557c3a59 authored by Craig Furman's avatar Craig Furman

Fix a log schema inconsistency

In JiraService, some structured logs for errors were sent with a Hash in
the error key, and some with a String. This frustrates Elasticsearch,
which is commonly used to store structured logs, causing it to have to
drop logs from one instance or the other due to the type mismatch.
parent f41c1194
...@@ -229,7 +229,15 @@ class JiraService < IssueTrackerService ...@@ -229,7 +229,15 @@ class JiraService < IssueTrackerService
jira_issue_transition_id.scan(Gitlab::Regex.jira_transition_id_regex).each do |transition_id| jira_issue_transition_id.scan(Gitlab::Regex.jira_transition_id_regex).each do |transition_id|
issue.transitions.build.save!(transition: { id: transition_id }) issue.transitions.build.save!(transition: { id: transition_id })
rescue => error rescue => error
log_error("Issue transition failed", error: error.message, client_url: client_url) log_error(
"Issue transition failed",
error: {
exception_class: error.class.name,
exception_message: error.message,
exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
},
client_url: client_url
)
return false return false
end end
end end
...@@ -354,7 +362,7 @@ class JiraService < IssueTrackerService ...@@ -354,7 +362,7 @@ class JiraService < IssueTrackerService
error: { error: {
exception_class: error.class.name, exception_class: error.class.name,
exception_message: error.message, exception_message: error.message,
exception_backtrace: error.backtrace.join("\n") exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
} }
) )
nil nil
......
...@@ -489,7 +489,14 @@ describe JiraService do ...@@ -489,7 +489,14 @@ describe JiraService do
@jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
expect(@jira_service).to have_received(:log_error).with("Issue transition failed", error: "Bad Request", client_url: "http://jira.example.com") expect(@jira_service).to have_received(:log_error).with(
"Issue transition failed",
error: hash_including(
exception_class: 'StandardError',
exception_message: "Bad Request"
),
client_url: "http://jira.example.com"
)
end end
it 'calls the api with jira_issue_transition_id' do it 'calls the api with jira_issue_transition_id' do
......
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