Commit daacafb8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'correlation-field-change' into 'master'

Rename correlation-id structured logging field to correlation_id

See merge request gitlab-org/gitlab-workhorse!343
parents dd755e07 cbef82cb
......@@ -4,6 +4,8 @@ Formerly known as 'gitlab-git-http-server'.
UNRELEASED
- Rename correlation-id structured logging field to correlation_id !343
v 7.5.0
- Add proxy layer to calculate content type and disposition headers !335
......
......@@ -28,11 +28,11 @@ func getCorrelationID(ctx context.Context) string {
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
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()
......@@ -40,22 +40,22 @@ func NoContext() *logrus.Logger {
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 {
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 {
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 {
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 {
return WithContext(ctx).WithError(err)
}
......@@ -19,8 +19,8 @@ func requireCorrelationID(t *testing.T, getEntry func(ctx context.Context) *logr
e := getEntry(ctx)
require.NotNil(t, e)
require.Contains(t, e.Data, "correlation-id")
require.Equal(t, id, e.Data["correlation-id"])
require.Contains(t, e.Data, "correlation_id")
require.Equal(t, id, e.Data["correlation_id"])
return e
}
......@@ -84,7 +84,7 @@ func TestNoContext(t *testing.T) {
require.Equal(t, logrus.StandardLogger(), logger)
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.Equal(t, value, e.Data[key])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment