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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
3560b119
Commit
3560b119
authored
Dec 06, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer to use correlation-id in logs
This changes `correlation_id` to be `correlation-id` when passed via jobs
parent
39c1731a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
12 additions
and
12 deletions
+12
-12
lib/gitlab/correlation_id.rb
lib/gitlab/correlation_id.rb
+1
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+1
-1
lib/gitlab/sentry.rb
lib/gitlab/sentry.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+1
-1
spec/initializers/lograge_spec.rb
spec/initializers/lograge_spec.rb
+3
-3
spec/lib/gitlab/json_logger_spec.rb
spec/lib/gitlab/json_logger_spec.rb
+2
-2
spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+1
-1
spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
...ib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
+1
-1
spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
.../lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
+1
-1
No files found.
lib/gitlab/correlation_id.rb
View file @
3560b119
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
module
Gitlab
module
Gitlab
module
CorrelationId
module
CorrelationId
LOG_KEY
=
'correlation
_
id'
.
freeze
LOG_KEY
=
'correlation
-
id'
.
freeze
class
<<
self
class
<<
self
def
use_id
(
correlation_id
,
&
blk
)
def
use_id
(
correlation_id
,
&
blk
)
...
...
lib/gitlab/gitaly_client.rb
View file @
3560b119
...
@@ -193,7 +193,7 @@ module Gitlab
...
@@ -193,7 +193,7 @@ module Gitlab
feature
=
feature_stack
&&
feature_stack
[
0
]
feature
=
feature_stack
&&
feature_stack
[
0
]
metadata
[
'call_site'
]
=
feature
.
to_s
if
feature
metadata
[
'call_site'
]
=
feature
.
to_s
if
feature
metadata
[
'gitaly-servers'
]
=
address_metadata
(
remote_storage
)
if
remote_storage
metadata
[
'gitaly-servers'
]
=
address_metadata
(
remote_storage
)
if
remote_storage
metadata
[
'correlation_id'
]
=
Gitlab
::
CorrelationId
.
current_id
if
Gitlab
::
CorrelationId
.
current_id
metadata
[
Gitlab
::
CorrelationId
::
LOG_KEY
]
=
Gitlab
::
CorrelationId
.
current_id
if
Gitlab
::
CorrelationId
.
current_id
metadata
.
merge!
(
server_feature_flags
)
metadata
.
merge!
(
server_feature_flags
)
...
...
lib/gitlab/sentry.rb
View file @
3560b119
...
@@ -45,7 +45,7 @@ module Gitlab
...
@@ -45,7 +45,7 @@ module Gitlab
context
# Make sure we've set everything we know in the context
context
# Make sure we've set everything we know in the context
tags
=
{
tags
=
{
Gitlab
::
CorrelationId
::
LOG_KEY
.
to_sym
=>
Gitlab
::
CorrelationId
.
current_id
correlation_id:
Gitlab
::
CorrelationId
.
current_id
}
}
Raven
.
capture_exception
(
exception
,
tags:
tags
,
extra:
extra
)
Raven
.
capture_exception
(
exception
,
tags:
tags
,
extra:
extra
)
...
...
spec/controllers/application_controller_spec.rb
View file @
3560b119
...
@@ -465,7 +465,7 @@ describe ApplicationController do
...
@@ -465,7 +465,7 @@ describe ApplicationController do
get
:index
get
:index
end
end
expect
(
controller
.
last_payload
).
to
include
(
'correlation
_
id'
=>
'new-id'
)
expect
(
controller
.
last_payload
).
to
include
(
'correlation
-
id'
=>
'new-id'
)
end
end
context
'422 errors'
do
context
'422 errors'
do
...
...
spec/initializers/lograge_spec.rb
View file @
3560b119
...
@@ -11,7 +11,7 @@ describe 'lograge', type: :request do
...
@@ -11,7 +11,7 @@ describe 'lograge', type: :request do
it
'logs to api_json log'
do
it
'logs to api_json log'
do
# we assert receiving parameters by grape logger
# we assert receiving parameters by grape logger
expect_any_instance_of
(
Gitlab
::
GrapeLogging
::
Formatters
::
LogrageWithTimestamp
).
to
receive
(
:call
)
expect_any_instance_of
(
Gitlab
::
GrapeLogging
::
Formatters
::
LogrageWithTimestamp
).
to
receive
(
:call
)
.
with
(
anything
,
anything
,
anything
,
a_hash_including
(
"correlation
_
id"
=>
"new-correlation-id"
))
.
with
(
anything
,
anything
,
anything
,
a_hash_including
(
"correlation
-
id"
=>
"new-correlation-id"
))
.
and_call_original
.
and_call_original
subject
subject
...
@@ -24,12 +24,12 @@ describe 'lograge', type: :request do
...
@@ -24,12 +24,12 @@ describe 'lograge', type: :request do
it
'logs to production_json log'
do
it
'logs to production_json log'
do
# formatter receives a hash with correlation id
# formatter receives a hash with correlation id
expect
(
Lograge
.
formatter
).
to
receive
(
:call
)
expect
(
Lograge
.
formatter
).
to
receive
(
:call
)
.
with
(
a_hash_including
(
"correlation
_
id"
=>
"new-correlation-id"
))
.
with
(
a_hash_including
(
"correlation
-
id"
=>
"new-correlation-id"
))
.
and_call_original
.
and_call_original
# a log file receives a line with correlation id
# a log file receives a line with correlation id
expect
(
Lograge
.
logger
).
to
receive
(
:send
)
expect
(
Lograge
.
logger
).
to
receive
(
:send
)
.
with
(
anything
,
include
(
'"correlation
_
id":"new-correlation-id"'
))
.
with
(
anything
,
include
(
'"correlation
-
id":"new-correlation-id"'
))
.
and_call_original
.
and_call_original
subject
subject
...
...
spec/lib/gitlab/json_logger_spec.rb
View file @
3560b119
...
@@ -18,7 +18,7 @@ describe Gitlab::JsonLogger do
...
@@ -18,7 +18,7 @@ describe Gitlab::JsonLogger do
expect
(
data
[
'severity'
]).
to
eq
(
'INFO'
)
expect
(
data
[
'severity'
]).
to
eq
(
'INFO'
)
expect
(
data
[
'time'
]).
to
eq
(
now
.
utc
.
iso8601
(
3
))
expect
(
data
[
'time'
]).
to
eq
(
now
.
utc
.
iso8601
(
3
))
expect
(
data
[
'message'
]).
to
eq
(
'Hello world'
)
expect
(
data
[
'message'
]).
to
eq
(
'Hello world'
)
expect
(
data
[
'correlation
_
id'
]).
to
eq
(
'new-correlation-id'
)
expect
(
data
[
'correlation
-
id'
]).
to
eq
(
'new-correlation-id'
)
end
end
it
'formats hashes'
do
it
'formats hashes'
do
...
@@ -29,7 +29,7 @@ describe Gitlab::JsonLogger do
...
@@ -29,7 +29,7 @@ describe Gitlab::JsonLogger do
expect
(
data
[
'time'
]).
to
eq
(
now
.
utc
.
iso8601
(
3
))
expect
(
data
[
'time'
]).
to
eq
(
now
.
utc
.
iso8601
(
3
))
expect
(
data
[
'hello'
]).
to
eq
(
1
)
expect
(
data
[
'hello'
]).
to
eq
(
1
)
expect
(
data
[
'message'
]).
to
be_nil
expect
(
data
[
'message'
]).
to
be_nil
expect
(
data
[
'correlation
_
id'
]).
to
eq
(
'new-correlation-id'
)
expect
(
data
[
'correlation
-
id'
]).
to
eq
(
'new-correlation-id'
)
end
end
end
end
end
end
spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
View file @
3560b119
...
@@ -13,7 +13,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
...
@@ -13,7 +13,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
"jid"
=>
"da883554ee4fe414012f5f42"
,
"jid"
=>
"da883554ee4fe414012f5f42"
,
"created_at"
=>
timestamp
.
to_f
,
"created_at"
=>
timestamp
.
to_f
,
"enqueued_at"
=>
timestamp
.
to_f
,
"enqueued_at"
=>
timestamp
.
to_f
,
"correlation
_
id"
=>
'cid'
"correlation
-
id"
=>
'cid'
}
}
end
end
let
(
:logger
)
{
double
()
}
let
(
:logger
)
{
double
()
}
...
...
spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
View file @
3560b119
...
@@ -37,7 +37,7 @@ describe Gitlab::SidekiqMiddleware::CorrelationInjector do
...
@@ -37,7 +37,7 @@ describe Gitlab::SidekiqMiddleware::CorrelationInjector do
expected_job_params
=
{
expected_job_params
=
{
"class"
=>
"TestWorker"
,
"class"
=>
"TestWorker"
,
"args"
=>
[
1234
],
"args"
=>
[
1234
],
"correlation
_
id"
=>
"new-correlation-id"
"correlation
-
id"
=>
"new-correlation-id"
}
}
expect
(
Sidekiq
::
Queues
.
jobs_by_worker
).
to
a_hash_including
(
expect
(
Sidekiq
::
Queues
.
jobs_by_worker
).
to
a_hash_including
(
...
...
spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
View file @
3560b119
...
@@ -30,6 +30,6 @@ describe Gitlab::SidekiqMiddleware::CorrelationLogger do
...
@@ -30,6 +30,6 @@ describe Gitlab::SidekiqMiddleware::CorrelationLogger do
'queue'
=>
'test'
,
'queue'
=>
'test'
,
'class'
=>
TestWorker
,
'class'
=>
TestWorker
,
'args'
=>
[
1234
],
'args'
=>
[
1234
],
'correlation
_
id'
=>
'new-correlation-id'
)
'correlation
-
id'
=>
'new-correlation-id'
)
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