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
857f0689
Commit
857f0689
authored
Feb 01, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant sidekiq exception logger
parent
e1cbe235
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
73 deletions
+2
-73
config/initializers/sidekiq.rb
config/initializers/sidekiq.rb
+2
-2
lib/gitlab/sidekiq_logging/exception_handler.rb
lib/gitlab/sidekiq_logging/exception_handler.rb
+0
-27
spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb
spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb
+0
-44
No files found.
config/initializers/sidekiq.rb
View file @
857f0689
...
...
@@ -31,9 +31,9 @@ Sidekiq.configure_server do |config|
Sidekiq
.
logger
.
formatter
=
Gitlab
::
SidekiqLogging
::
JSONFormatter
.
new
config
.
options
[
:job_logger
]
=
Gitlab
::
SidekiqLogging
::
StructuredLogger
# Remove the default-provided handler
# Remove the default-provided handler. The exception is logged inside
# Gitlab::SidekiqLogging::StructuredLogger
config
.
error_handlers
.
reject!
{
|
handler
|
handler
.
is_a?
(
Sidekiq
::
ExceptionHandler
::
Logger
)
}
config
.
error_handlers
<<
Gitlab
::
SidekiqLogging
::
ExceptionHandler
.
new
end
config
.
redis
=
queues_config_hash
...
...
lib/gitlab/sidekiq_logging/exception_handler.rb
deleted
100644 → 0
View file @
e1cbe235
# frozen_string_literal: true
module
Gitlab
module
SidekiqLogging
class
ExceptionHandler
def
call
(
job_exception
,
context
)
data
=
{
error_class:
job_exception
.
class
.
name
,
error_message:
job_exception
.
message
}
if
context
.
is_a?
(
Hash
)
data
.
merge!
(
context
)
# correlation_id, jid, and class are available inside the job
# Hash, so promote these arguments to the root tree so that
# can be searched alongside other Sidekiq log messages.
job_data
=
data
.
delete
(
:job
)
data
.
merge!
(
job_data
)
if
job_data
.
present?
end
data
[
:error_backtrace
]
=
Rails
.
backtrace_cleaner
.
clean
(
job_exception
.
backtrace
)
if
job_exception
.
backtrace
.
present?
Sidekiq
.
logger
.
warn
(
data
)
end
end
end
end
spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb
deleted
100644 → 0
View file @
e1cbe235
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
SidekiqLogging
::
ExceptionHandler
do
describe
'#call'
do
let
(
:job
)
do
{
"class"
=>
"TestWorker"
,
"args"
=>
[
1234
,
'hello'
],
"retry"
=>
false
,
"queue"
=>
"cronjob:test_queue"
,
"queue_namespace"
=>
"cronjob"
,
"jid"
=>
"da883554ee4fe414012f5f42"
,
"correlation_id"
=>
'cid'
}
end
let
(
:exception_message
)
{
'An error was thrown'
}
let
(
:backtrace
)
{
caller
}
let
(
:exception
)
{
RuntimeError
.
new
(
exception_message
)
}
let
(
:logger
)
{
double
}
before
do
allow
(
Sidekiq
).
to
receive
(
:logger
).
and_return
(
logger
)
allow
(
exception
).
to
receive
(
:backtrace
).
and_return
(
backtrace
)
end
subject
{
described_class
.
new
.
call
(
exception
,
{
context:
'Test'
,
job:
job
})
}
it
'logs job data into root tree'
do
expected_data
=
job
.
merge
(
error_class:
'RuntimeError'
,
error_message:
exception_message
,
context:
'Test'
,
error_backtrace:
Rails
.
backtrace_cleaner
.
clean
(
backtrace
)
)
expect
(
logger
).
to
receive
(
:warn
).
with
(
expected_data
)
subject
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