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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-09-03 19:50:44 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-09-03 19:50:44 +0300
commit8d3193e3f6d448879ebab5926a226cac8590a70c (patch)
treea365c6effe71f6a81d3c3ebfe6aababb69751d6d
parent85dab6bcb4c37c44fe67fc2d85e571e544b5396c (diff)
parentdd99d044b73f648bd0d3f8f242c855996e0e9b52 (diff)
Merge branch 'zj-logging-praefect-fix' into 'master'
Update logging to leverage fields better Closes #1883 See merge request gitlab-org/gitaly!1468
-rw-r--r--changelogs/unreleased/zj-logging-praefect-fix.yml5
-rw-r--r--internal/praefect/replicator.go24
2 files changed, 20 insertions, 9 deletions
diff --git a/changelogs/unreleased/zj-logging-praefect-fix.yml b/changelogs/unreleased/zj-logging-praefect-fix.yml
new file mode 100644
index 000000000..a8bb01f84
--- /dev/null
+++ b/changelogs/unreleased/zj-logging-praefect-fix.yml
@@ -0,0 +1,5 @@
+---
+title: Update logging statements to leverage structured logging better
+merge_request:
+author:
+type: other
diff --git a/internal/praefect/replicator.go b/internal/praefect/replicator.go
index f54a6f457..8e41c3879 100644
--- a/internal/praefect/replicator.go
+++ b/internal/praefect/replicator.go
@@ -124,18 +124,17 @@ func (r ReplMgr) ScheduleReplication(ctx context.Context, repo models.Repository
return err
}
- r.log.Infof(
- "replication manager for targetNode %q created replication job with ID %d",
- r.targetNode,
- id,
- )
+ r.log.WithFields(logrus.Fields{
+ logWithReplJobID: id,
+ "relative_path": repo.RelativePath,
+ }).Info("replication job created")
return nil
}
const (
jobFetchInterval = 10 * time.Millisecond
- logWithReplJobID = "replication-job-ID"
+ logWithReplJobID = "replication_job_id"
)
// ProcessBacklog will process queued jobs. It will block while processing jobs.
@@ -153,7 +152,10 @@ func (r ReplMgr) ProcessBacklog(ctx context.Context) error {
}
if len(jobs) == 0 {
- r.log.Tracef("no jobs for %d, checking again in %s", node.ID, jobFetchInterval)
+ r.log.WithFields(logrus.Fields{
+ "node_id": node.ID,
+ "recheck_interval": jobFetchInterval,
+ }).Trace("no jobs")
select {
// TODO: exponential backoff when no queries are returned
@@ -166,8 +168,12 @@ func (r ReplMgr) ProcessBacklog(ctx context.Context) error {
}
for _, job := range jobs {
- r.log.WithField(logWithReplJobID, job.ID).
- Infof("processing replication job %#v", job)
+ r.log.WithFields(logrus.Fields{
+ logWithReplJobID: job.ID,
+ "from_storage": job.SourceNode.Storage,
+ "to_storage": job.TargetNode.Storage,
+ "relative_path": job.Repository.RelativePath,
+ }).Info("processing replication job")
if err := r.datastore.UpdateReplJob(job.ID, JobStateInProgress); err != nil {
return err