Skip to content

Commit

Permalink
fix: add logs and metrics around pusher retries
Browse files Browse the repository at this point in the history
  • Loading branch information
Eknir committed Jun 7, 2021
1 parent 24121ff commit 5b9541c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 8 additions & 1 deletion pkg/pusher/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type metrics struct {
SyncTime prometheus.Histogram
ErrorTime prometheus.Histogram

ReceiptDepth *prometheus.CounterVec
ReceiptDepth *prometheus.CounterVec
ShallowRetries prometheus.Counter
}

func newMetrics() metrics {
Expand Down Expand Up @@ -72,6 +73,12 @@ func newMetrics() metrics {
},
[]string{"depth"},
),
ShallowRetries: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "shallow_retries",
Help: "Chunks retried because receipts were too shallow",
}),
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/pusher/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ LOOP:
s.metrics.TotalSynced.Inc()
s.metrics.SyncTime.Observe(time.Since(startTime).Seconds())
// only print this if there was no error while sending the chunk
logger.Tracef("pusher: pushed chunk %s to node %s", ch.Address().String(), storerPeer.String())
po := swarm.Proximity(ch.Address().Bytes(), storerPeer.Bytes())
logger.Tracef("pusher: pushed chunk %s to node %s with receipt depth %d", ch.Address().String(), storerPeer.String(), po)
s.metrics.ReceiptDepth.WithLabelValues(strconv.Itoa(int(po))).Inc()
delete(retryCounter, ch.Address().ByteString())
} else {
Expand Down Expand Up @@ -203,12 +203,13 @@ LOOP:
d := s.depther.NeighborhoodDepth()
if po < d {
mtx.Lock()
retryCounter[ch.Address().ByteString()]++
if retryCounter[ch.Address().ByteString()] < retryCount {
retryCounter[ch.Address().ByteString()]++
mtx.Unlock()
err = fmt.Errorf("pusher: shallow receipt depth %d, want at least %d", po, d)
po := swarm.Proximity(ch.Address().Bytes(), storerPeer.Bytes())
s.metrics.ReceiptDepth.WithLabelValues(strconv.Itoa(int(po))).Inc()
// QUESTION: where is this error logged?
err = fmt.Errorf("pusher: reshallow receipt depth %d from chunk %s, want at least %d", po, ch.Address().String(), d)
s.metrics.ShallowRetries.Inc()
return
}
mtx.Unlock()
Expand Down

0 comments on commit 5b9541c

Please sign in to comment.