Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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-workhorse
Commits
cbef82cb
Commit
cbef82cb
authored
Dec 10, 2018
by
Andrew Newdigate
Committed by
Jacob Vosmaer
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename correlation-id structured logging field to correlation_id
parent
dd755e07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
CHANGELOG
CHANGELOG
+2
-0
internal/log/logrus.go
internal/log/logrus.go
+7
-7
internal/log/logrus_test.go
internal/log/logrus_test.go
+3
-3
No files found.
CHANGELOG
View file @
cbef82cb
...
@@ -4,6 +4,8 @@ Formerly known as 'gitlab-git-http-server'.
...
@@ -4,6 +4,8 @@ Formerly known as 'gitlab-git-http-server'.
UNRELEASED
UNRELEASED
- Rename correlation-id structured logging field to correlation_id !343
v 7.5.0
v 7.5.0
- Add proxy layer to calculate content type and disposition headers !335
- Add proxy layer to calculate content type and disposition headers !335
...
...
internal/log/logrus.go
View file @
cbef82cb
...
@@ -28,11 +28,11 @@ func getCorrelationID(ctx context.Context) string {
...
@@ -28,11 +28,11 @@ func getCorrelationID(ctx context.Context) string {
return
correlationID
return
correlationID
}
}
// WithContext provides a *logrus.Entry with the proper "correlation
-
id" field.
// WithContext provides a *logrus.Entry with the proper "correlation
_
id" field.
//
//
// "[MISSING]" will be used when ctx has no value for KeyCorrelationID
// "[MISSING]" will be used when ctx has no value for KeyCorrelationID
func
WithContext
(
ctx
context
.
Context
)
*
logrus
.
Entry
{
func
WithContext
(
ctx
context
.
Context
)
*
logrus
.
Entry
{
return
logrus
.
WithField
(
"correlation
-
id"
,
getCorrelationID
(
ctx
))
return
logrus
.
WithField
(
"correlation
_
id"
,
getCorrelationID
(
ctx
))
}
}
// NoContext provides logrus.StandardLogger()
// NoContext provides logrus.StandardLogger()
...
@@ -40,22 +40,22 @@ func NoContext() *logrus.Logger {
...
@@ -40,22 +40,22 @@ func NoContext() *logrus.Logger {
return
logrus
.
StandardLogger
()
return
logrus
.
StandardLogger
()
}
}
// WrapEntry adds the proper "correlation
-
id" field to the provided *logrus.Entry
// WrapEntry adds the proper "correlation
_
id" field to the provided *logrus.Entry
func
WrapEntry
(
ctx
context
.
Context
,
e
*
logrus
.
Entry
)
*
logrus
.
Entry
{
func
WrapEntry
(
ctx
context
.
Context
,
e
*
logrus
.
Entry
)
*
logrus
.
Entry
{
return
e
.
WithField
(
"correlation
-
id"
,
getCorrelationID
(
ctx
))
return
e
.
WithField
(
"correlation
_
id"
,
getCorrelationID
(
ctx
))
}
}
// WithFields decorates logrus.WithFields with the proper "correlation
-
id"
// WithFields decorates logrus.WithFields with the proper "correlation
_
id"
func
WithFields
(
ctx
context
.
Context
,
f
Fields
)
*
logrus
.
Entry
{
func
WithFields
(
ctx
context
.
Context
,
f
Fields
)
*
logrus
.
Entry
{
return
WithContext
(
ctx
)
.
WithFields
(
toLogrusFields
(
f
))
return
WithContext
(
ctx
)
.
WithFields
(
toLogrusFields
(
f
))
}
}
// WithField decorates logrus.WithField with the proper "correlation
-
id"
// WithField decorates logrus.WithField with the proper "correlation
_
id"
func
WithField
(
ctx
context
.
Context
,
key
string
,
value
interface
{})
*
logrus
.
Entry
{
func
WithField
(
ctx
context
.
Context
,
key
string
,
value
interface
{})
*
logrus
.
Entry
{
return
WithContext
(
ctx
)
.
WithField
(
key
,
value
)
return
WithContext
(
ctx
)
.
WithField
(
key
,
value
)
}
}
// WithError decorates logrus.WithError with the proper "correlation
-
id"
// WithError decorates logrus.WithError with the proper "correlation
_
id"
func
WithError
(
ctx
context
.
Context
,
err
error
)
*
logrus
.
Entry
{
func
WithError
(
ctx
context
.
Context
,
err
error
)
*
logrus
.
Entry
{
return
WithContext
(
ctx
)
.
WithError
(
err
)
return
WithContext
(
ctx
)
.
WithError
(
err
)
}
}
internal/log/logrus_test.go
View file @
cbef82cb
...
@@ -19,8 +19,8 @@ func requireCorrelationID(t *testing.T, getEntry func(ctx context.Context) *logr
...
@@ -19,8 +19,8 @@ func requireCorrelationID(t *testing.T, getEntry func(ctx context.Context) *logr
e
:=
getEntry
(
ctx
)
e
:=
getEntry
(
ctx
)
require
.
NotNil
(
t
,
e
)
require
.
NotNil
(
t
,
e
)
require
.
Contains
(
t
,
e
.
Data
,
"correlation
-
id"
)
require
.
Contains
(
t
,
e
.
Data
,
"correlation
_
id"
)
require
.
Equal
(
t
,
id
,
e
.
Data
[
"correlation
-
id"
])
require
.
Equal
(
t
,
id
,
e
.
Data
[
"correlation
_
id"
])
return
e
return
e
}
}
...
@@ -84,7 +84,7 @@ func TestNoContext(t *testing.T) {
...
@@ -84,7 +84,7 @@ func TestNoContext(t *testing.T) {
require
.
Equal
(
t
,
logrus
.
StandardLogger
(),
logger
)
require
.
Equal
(
t
,
logrus
.
StandardLogger
(),
logger
)
e
:=
logger
.
WithField
(
key
,
value
)
e
:=
logger
.
WithField
(
key
,
value
)
require
.
NotContains
(
t
,
e
.
Data
,
"correlation
-
id"
)
require
.
NotContains
(
t
,
e
.
Data
,
"correlation
_
id"
)
require
.
Contains
(
t
,
e
.
Data
,
key
)
require
.
Contains
(
t
,
e
.
Data
,
key
)
require
.
Equal
(
t
,
value
,
e
.
Data
[
key
])
require
.
Equal
(
t
,
value
,
e
.
Data
[
key
])
...
...
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