Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-07-07 05:19:48 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-07-07 05:19:48 +0300
commit86afc1dfeeb07fbc140d08ef8cdcfd8cbd4d7bcb (patch)
tree41a2d15d113a8dba2513ca42d9c82722d1c5892b /internal/vfs
parente74c91bfe5c95d6da82691e0c753cc50b661613c (diff)
Improve logging and correlation ID
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/root.go13
-rw-r--r--internal/vfs/vfs.go9
-rw-r--r--internal/vfs/zip/archive.go6
3 files changed, 15 insertions, 13 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")
diff --git a/internal/vfs/vfs.go b/internal/vfs/vfs.go
index 2304f903..40fe8bc7 100644
--- a/internal/vfs/vfs.go
+++ b/internal/vfs/vfs.go
@@ -4,7 +4,8 @@ import (
"context"
"strconv"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/labkit/log"
"gitlab.com/gitlab-org/gitlab-pages/internal/config"
"gitlab.com/gitlab-org/gitlab-pages/metrics"
@@ -29,15 +30,15 @@ func (i *instrumentedVFS) increment(operation string, err error) {
metrics.VFSOperations.WithLabelValues(i.fs.Name(), operation, strconv.FormatBool(err == nil)).Inc()
}
-func (i *instrumentedVFS) log() *log.Entry {
- return log.WithField("vfs", i.fs.Name())
+func (i *instrumentedVFS) log(ctx context.Context) *logrus.Entry {
+ return log.ContextLogger(ctx).WithField("vfs", i.fs.Name())
}
func (i *instrumentedVFS) Root(ctx context.Context, path string) (Root, error) {
root, err := i.fs.Root(ctx, path)
i.increment("Root", err)
- i.log().
+ i.log(ctx).
WithField("path", path).
WithError(err).
Traceln("Root call")
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go
index 981881c0..087ddda8 100644
--- a/internal/vfs/zip/archive.go
+++ b/internal/vfs/zip/archive.go
@@ -14,7 +14,7 @@ import (
"sync/atomic"
"time"
- log "github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/labkit/log"
"gitlab.com/gitlab-org/gitlab-pages/internal/httprange"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
@@ -101,9 +101,9 @@ func (a *zipArchive) openArchive(parentCtx context.Context, url string) (err err
err := ctx.Err()
switch err {
case context.Canceled:
- log.WithError(err).Traceln("open zip archive request canceled")
+ log.ContextLogger(parentCtx).WithError(err).Traceln("open zip archive request canceled")
case context.DeadlineExceeded:
- log.WithError(err).Traceln("open zip archive timed out")
+ log.ContextLogger(parentCtx).WithError(err).Traceln("open zip archive timed out")
}
return err