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
9a074489
Commit
9a074489
authored
Apr 30, 2021
by
Nikola Milojevic
Committed by
Kamil Trzciński
Apr 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add database-chosen to the structured log
parent
876a10fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
ee/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
ee/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+18
-0
lib/gitlab/sidekiq_logging/structured_logger.rb
lib/gitlab/sidekiq_logging/structured_logger.rb
+2
-0
No files found.
ee/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
View file @
9a074489
...
...
@@ -106,6 +106,24 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
end
end
context
'when the job uses load balancing capabilities'
do
let
(
:expected_payload
)
{
{
'database_chosen'
=>
'retry'
}
}
before
do
allow
(
Time
).
to
receive
(
:now
).
and_return
(
timestamp
)
allow
(
Process
).
to
receive
(
:clock_gettime
).
and_call_original
end
it
'logs the database chosen'
do
expect
(
logger
).
to
receive
(
:info
).
with
(
start_payload
).
ordered
expect
(
logger
).
to
receive
(
:info
).
with
(
include
(
expected_payload
)).
ordered
call_subject
(
job
,
'test_queue'
)
do
job
[
:database_chosen
]
=
'retry'
end
end
end
def
call_subject
(
job
,
queue
)
# This structured logger strongly depends on execution of `InstrumentationLogger`
subject
.
call
(
job
,
queue
)
do
...
...
lib/gitlab/sidekiq_logging/structured_logger.rb
View file @
9a074489
...
...
@@ -70,6 +70,8 @@ module Gitlab
message
=
base_message
(
payload
)
payload
[
'database_chosen'
]
=
job
[
:database_chosen
]
if
job
[
:database_chosen
]
if
job_exception
payload
[
'message'
]
=
"
#{
message
}
: fail:
#{
payload
[
'duration_s'
]
}
sec"
payload
[
'job_status'
]
=
'fail'
...
...
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