Skip to content

Commit

Permalink
feat(pusher): receipt depth metric
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Jun 3, 2021
1 parent 3e60bfc commit abd51c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/pusher/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type metrics struct {
MarkAndSweepTime prometheus.Histogram
SyncTime prometheus.Histogram
ErrorTime prometheus.Histogram

ReceiptDepth *prometheus.CounterVec
}

func newMetrics() metrics {
Expand Down Expand Up @@ -61,6 +63,15 @@ func newMetrics() metrics {
Help: "Histogram of time spent before giving up on syncing a chunk.",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10, 60},
}),
ReceiptDepth: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "receipt_depth",
Help: "Counter of receipts received at different depths.",
},
[]string{"depth"},
),
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/pusher/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -148,6 +149,8 @@ LOOP:
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())
s.metrics.ReceiptDepth.WithLabelValues(strconv.Itoa(int(po))).Inc()
} else {
s.metrics.TotalErrors.Inc()
s.metrics.ErrorTime.Observe(time.Since(startTime).Seconds())
Expand Down

0 comments on commit abd51c6

Please sign in to comment.