Commit e174373a authored by acud's avatar acud Committed by GitHub

feat(pusher): receipt depth metric (#1977)

parent 9dd380c4
......@@ -16,6 +16,8 @@ type metrics struct {
MarkAndSweepTime prometheus.Histogram
SyncTime prometheus.Histogram
ErrorTime prometheus.Histogram
ReceiptDepth *prometheus.CounterVec
}
func newMetrics() metrics {
......@@ -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"},
),
}
}
......
......@@ -13,6 +13,7 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"strconv"
"sync"
"time"
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment