diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-07 05:19:48 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-07 05:19:48 +0300 |
commit | 86afc1dfeeb07fbc140d08ef8cdcfd8cbd4d7bcb (patch) | |
tree | 41a2d15d113a8dba2513ca42d9c82722d1c5892b /internal/vfs/root.go | |
parent | e74c91bfe5c95d6da82691e0c753cc50b661613c (diff) |
Improve logging and correlation ID
Diffstat (limited to 'internal/vfs/root.go')
-rw-r--r-- | internal/vfs/root.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/vfs/root.go b/internal/vfs/root.go index 30d97b0b..9c7528b3 100644 --- a/internal/vfs/root.go +++ b/internal/vfs/root.go @@ -5,7 +5,8 @@ import ( "os" "strconv" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/labkit/log" "gitlab.com/gitlab-org/gitlab-pages/metrics" ) @@ -27,15 +28,15 @@ func (i *instrumentedRoot) increment(operation string, err error) { metrics.VFSOperations.WithLabelValues(i.name, operation, strconv.FormatBool(err == nil)).Inc() } -func (i *instrumentedRoot) log() *log.Entry { - return log.WithField("vfs", i.name).WithField("root-path", i.rootPath) +func (i *instrumentedRoot) log(ctx context.Context) *logrus.Entry { + return log.ContextLogger(ctx).WithField("vfs", i.name).WithField("root-path", i.rootPath) } func (i *instrumentedRoot) Lstat(ctx context.Context, name string) (os.FileInfo, error) { fi, err := i.root.Lstat(ctx, name) i.increment("Lstat", err) - i.log(). + i.log(ctx). WithField("name", name). WithError(err). Traceln("Lstat call") @@ -47,7 +48,7 @@ func (i *instrumentedRoot) Readlink(ctx context.Context, name string) (string, e target, err := i.root.Readlink(ctx, name) i.increment("Readlink", err) - i.log(). + i.log(ctx). WithField("name", name). WithField("ret-target", target). WithError(err). @@ -60,7 +61,7 @@ func (i *instrumentedRoot) Open(ctx context.Context, name string) (File, error) f, err := i.root.Open(ctx, name) i.increment("Open", err) - i.log(). + i.log(ctx). WithField("name", name). WithError(err). Traceln("Open call") |