Skip to content

Commit

Permalink
Tidy up log messages
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Jan 30, 2024
1 parent 833f798 commit 9b7a91a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/server/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
w.wg.Add(1)

key := string(r.Key)
startRevision := r.StartRevision

var progressCh chan int64
if r.ProgressNotify {
progressCh = make(chan int64)
w.progress[id] = progressCh
}

logrus.Tracef("WATCH START id=%d, count=%d, key=%s, revision=%d, progressNotify=%v", id, len(w.watches), key, r.StartRevision, r.ProgressNotify)
startRevision := r.StartRevision
logrus.Tracef("WATCH START id=%d, key=%s, revision=%d, progressNotify=%v, watchCount=%d", id, key, startRevision, r.ProgressNotify, len(w.watches))

go func() {
defer w.wg.Done()
Expand All @@ -107,7 +107,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
return
}

wr := w.backend.Watch(ctx, key, r.StartRevision)
wr := w.backend.Watch(ctx, key, startRevision)

// If the watch result has a non-zero CompactRevision, then the watch request failed due to
// the requested start revision having been compacted. Pass the current and and compact
Expand All @@ -117,6 +117,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
return
}

trace := logrus.IsLevelEnabled(logrus.TraceLevel)
outer := true
for outer {
var reads int
Expand Down Expand Up @@ -150,7 +151,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
// get max revision from collected events
if len(events) > 0 {
revision = events[len(events)-1].KV.ModRevision
if logrus.IsLevelEnabled(logrus.TraceLevel) {
if trace {
for _, event := range events {
logrus.Tracef("WATCH READ id=%d, key=%s, revision=%d", id, event.KV.Key, event.KV.ModRevision)
}
Expand All @@ -164,7 +165,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
WatchId: id,
Events: toEvents(events...),
}
logrus.Tracef("WATCH SEND id=%d, revision=%d, events=%d, size=%d reads=%d", id, revision, len(wr.Events), wr.Size(), reads)
logrus.Tracef("WATCH SEND id=%d, key=%s, revision=%d, events=%d, size=%d, reads=%d", id, key, revision, len(wr.Events), wr.Size(), reads)
if err := w.server.Send(wr); err != nil {
w.Cancel(id, 0, 0, err)
}
Expand Down

0 comments on commit 9b7a91a

Please sign in to comment.