Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
834abb31
Commit
834abb31
authored
Feb 23, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code review feedback
Issue
https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/846
parent
b72f27c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
10 deletions
+14
-10
lib/gitlab/error_tracking.rb
lib/gitlab/error_tracking.rb
+3
-2
lib/gitlab/error_tracking/log_formatter.rb
lib/gitlab/error_tracking/log_formatter.rb
+10
-4
spec/lib/gitlab/error_tracking/log_formatter_spec.rb
spec/lib/gitlab/error_tracking/log_formatter_spec.rb
+1
-3
spec/lib/gitlab/error_tracking/processor/context_payload_processor_spec.rb
...rror_tracking/processor/context_payload_processor_spec.rb
+0
-1
No files found.
lib/gitlab/error_tracking.rb
View file @
834abb31
...
...
@@ -108,8 +108,9 @@ module Gitlab
end
if
logging
log_hash
=
{}
Gitlab
::
ErrorTracking
::
LogFormatter
.
format!
(
log_hash
,
exception
,
context_payload
)
formater
=
Gitlab
::
ErrorTracking
::
LogFormatter
.
new
log_hash
=
formater
.
generate_log
(
exception
,
context_payload
)
Gitlab
::
ErrorTracking
::
Logger
.
error
(
log_hash
)
end
end
...
...
lib/gitlab/error_tracking/log_formatter.rb
View file @
834abb31
...
...
@@ -6,28 +6,34 @@ module Gitlab
# Note: all the accesses to Raven's contexts here are to keep the
# backward-compatibility to Sentry's built-in integrations. In future,
# they can be removed.
def
self
.
format!
(
payload
,
exception
,
context_payload
)
def
generate_log
(
exception
,
context_payload
)
payload
=
{}
Gitlab
::
ExceptionLogFormatter
.
format!
(
exception
,
payload
)
append_user_to_log!
(
payload
,
context_payload
)
append_tags_to_log!
(
payload
,
context_payload
)
append_extra_to_log!
(
payload
,
context_payload
)
payload
end
def
self
.
append_user_to_log!
(
payload
,
context_payload
)
private
def
append_user_to_log!
(
payload
,
context_payload
)
user_context
=
Raven
.
context
.
user
.
merge
(
context_payload
[
:user
])
user_context
.
each
do
|
key
,
value
|
payload
[
"user.
#{
key
}
"
]
=
value
end
end
def
self
.
append_tags_to_log!
(
payload
,
context_payload
)
def
append_tags_to_log!
(
payload
,
context_payload
)
tags_context
=
Raven
.
context
.
tags
.
merge
(
context_payload
[
:tags
])
tags_context
.
each
do
|
key
,
value
|
payload
[
"tags.
#{
key
}
"
]
=
value
end
end
def
self
.
append_extra_to_log!
(
payload
,
context_payload
)
def
append_extra_to_log!
(
payload
,
context_payload
)
extra
=
Raven
.
context
.
extra
.
merge
(
context_payload
[
:extra
])
extra
=
extra
.
except
(
:server
)
...
...
spec/lib/gitlab/error_tracking/log_formatter_spec.rb
View file @
834abb31
...
...
@@ -43,9 +43,7 @@ RSpec.describe Gitlab::ErrorTracking::LogFormatter do
end
it
'appends error-related log fields'
do
payload
=
{}
described_class
.
format!
(
payload
,
exception
,
context_payload
)
payload
=
described_class
.
new
.
generate_log
(
exception
,
context_payload
)
expect
(
payload
).
to
eql
(
'exception.class'
=>
'StandardError'
,
...
...
spec/lib/gitlab/error_tracking/processor/context_payload_processor_spec.rb
View file @
834abb31
# frozen_string_literal: true
require
'spec_helper'
require
'rspec-parameterized'
RSpec
.
describe
Gitlab
::
ErrorTracking
::
Processor
::
ContextPayloadProcessor
do
subject
(
:processor
)
{
described_class
.
new
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment