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
fe1625bb
Commit
fe1625bb
authored
Mar 17, 2018
by
Valery Sizov
Committed by
Stan Hu
Mar 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Geo] Log Sidekiq context for sync related jobs
parent
4dfeb060
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
ee/changelogs/unreleased/4994-geo-log-jid-for-sync-related-jobs.yml
...ogs/unreleased/4994-geo-log-jid-for-sync-related-jobs.yml
+5
-0
ee/lib/gitlab/geo/log_helpers.rb
ee/lib/gitlab/geo/log_helpers.rb
+17
-2
ee/lib/gitlab/geo/project_log_helpers.rb
ee/lib/gitlab/geo/project_log_helpers.rb
+3
-2
ee/spec/lib/gitlab/geo/log_helpers_spec.rb
ee/spec/lib/gitlab/geo/log_helpers_spec.rb
+39
-0
No files found.
ee/changelogs/unreleased/4994-geo-log-jid-for-sync-related-jobs.yml
0 → 100644
View file @
fe1625bb
---
title
:
"
[Geo]
Log
JID
for
sync
related
jobs"
merge_request
:
author
:
type
:
other
ee/lib/gitlab/geo/log_helpers.rb
View file @
fe1625bb
module
Gitlab
module
Geo
module
LogHelpers
SIDEKIQ_JID_LENGTH
=
24
def
log_info
(
message
,
details
=
{})
data
=
base_log_data
(
message
)
data
.
merge!
(
details
)
if
details
...
...
@@ -19,13 +21,26 @@ module Gitlab
def
base_log_data
(
message
)
{
class:
self
.
class
.
name
,
message:
message
}
message:
message
,
job_id:
get_sidekiq_job_id
}.
compact
end
def
geo_logger
Gitlab
::
Geo
::
Logger
end
def
get_sidekiq_job_id
context_data
=
Thread
.
current
[
:sidekiq_context
]
&
.
first
return
unless
context_data
index
=
context_data
.
index
(
'JID-'
)
return
unless
index
context_data
[
index
+
4
..-
1
]
end
end
end
end
ee/lib/gitlab/geo/project_log_helpers.rb
View file @
fe1625bb
...
...
@@ -9,8 +9,9 @@ module Gitlab
project_id:
project
.
id
,
project_path:
project
.
full_path
,
storage_version:
project
.
storage_version
,
message:
message
}
message:
message
,
job_id:
get_sidekiq_job_id
}.
compact
end
end
end
...
...
ee/spec/lib/gitlab/geo/log_helpers_spec.rb
0 → 100644
View file @
fe1625bb
require
'spec_helper'
describe
Gitlab
::
Geo
::
LogHelpers
do
class
FakeLogHelpersConsumer
include
Gitlab
::
Geo
::
LogHelpers
def
execute
log_error
(
'Test message'
)
end
end
def
stub_sidekiq_job_context
(
context
)
original_value
=
Thread
.
current
[
:sidekiq_context
]
Thread
.
current
[
:sidekiq_context
]
=
context
yield
Thread
.
current
[
:sidekiq_context
]
=
original_value
end
context
'Sidekiq context'
do
it
'does not log empty job_id when running outside of job'
do
expect
(
Gitlab
::
Geo
::
Logger
).
to
receive
(
:error
).
with
({
class:
'FakeLogHelpersConsumer'
,
message:
'Test message'
})
FakeLogHelpersConsumer
.
new
.
execute
end
it
'logs sidekiq_context'
do
expect
(
Gitlab
::
Geo
::
Logger
).
to
receive
(
:error
).
with
({
class:
'FakeLogHelpersConsumer'
,
message:
'Test message'
,
job_id:
'5b9b108c7558fe3c32cc61a5'
})
stub_sidekiq_job_context
([
'TestWorker JID-5b9b108c7558fe3c32cc61a5'
])
do
FakeLogHelpersConsumer
.
new
.
execute
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