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
32126195
Commit
32126195
authored
May 29, 2020
by
Igor
Committed by
Igor Drozdov
May 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure json.extra.sidekiq conforms to logging schema
parent
ed4b163b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
lib/gitlab/exception_log_formatter.rb
lib/gitlab/exception_log_formatter.rb
+15
-0
spec/lib/gitlab/error_tracking_spec.rb
spec/lib/gitlab/error_tracking_spec.rb
+11
-0
No files found.
lib/gitlab/exception_log_formatter.rb
View file @
32126195
...
@@ -14,6 +14,21 @@ module Gitlab
...
@@ -14,6 +14,21 @@ module Gitlab
payload
.
delete
(
'extra.server'
)
payload
.
delete
(
'extra.server'
)
# The raven extra context is populated by Raven::SidekiqCleanupMiddleware.
#
# It contains the full sidekiq job which consists of mixed types and nested
# objects. That causes a bunch of issues when trying to ingest logs into
# Elasticsearch.
#
# We apply a stricter schema here that forces the args to be an array of
# strings. This same logic exists in Gitlab::SidekiqLogging::JSONFormatter.
payload
[
'extra.sidekiq'
].
tap
do
|
value
|
if
value
.
is_a?
(
Hash
)
&&
value
.
key?
(
'args'
)
value
=
value
.
dup
payload
[
'extra.sidekiq'
][
'args'
]
=
Gitlab
::
Utils
::
LogLimitedArray
.
log_limited_array
(
value
[
'args'
].
try
(
:map
,
&
:to_s
))
end
end
if
exception
.
backtrace
if
exception
.
backtrace
payload
[
'exception.backtrace'
]
=
Gitlab
::
BacktraceCleaner
.
clean_backtrace
(
exception
.
backtrace
)
payload
[
'exception.backtrace'
]
=
Gitlab
::
BacktraceCleaner
.
clean_backtrace
(
exception
.
backtrace
)
end
end
...
...
spec/lib/gitlab/error_tracking_spec.rb
View file @
32126195
...
@@ -179,5 +179,16 @@ describe Gitlab::ErrorTracking do
...
@@ -179,5 +179,16 @@ describe Gitlab::ErrorTracking do
described_class
.
track_exception
(
exception
,
extra_info
)
described_class
.
track_exception
(
exception
,
extra_info
)
end
end
end
end
context
'with sidekiq args'
do
let
(
:extra
)
{
{
sidekiq:
{
'args'
=>
[
1
,
{
'id'
=>
2
,
'name'
=>
'hello'
},
'some-value'
,
'another-value'
]
}
}
}
it
'ensures extra.sidekiq.args is a string'
do
expect
(
Gitlab
::
ErrorTracking
::
Logger
).
to
receive
(
:error
).
with
(
hash_including
({
'extra.sidekiq'
=>
{
'args'
=>
[
'1'
,
'{"id"=>2, "name"=>"hello"}'
,
'some-value'
,
'another-value'
]
}
}))
described_class
.
track_exception
(
exception
,
extra
)
end
end
end
end
end
end
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