Commit 4e19f015 authored by asnared's avatar asnared

fix: metrics histogram

parent 117fd621
...@@ -114,7 +114,7 @@ type Metrics struct { ...@@ -114,7 +114,7 @@ type Metrics struct {
// P2P Metrics // P2P Metrics
PeerCount prometheus.Gauge PeerCount prometheus.Gauge
StreamCount prometheus.Gauge StreamCount prometheus.Gauge
PeerScores map[peer.ID]float64 PeerScores *prometheus.HistogramVec
GossipEventsTotal *prometheus.CounterVec GossipEventsTotal *prometheus.CounterVec
BandwidthTotal *prometheus.GaugeVec BandwidthTotal *prometheus.GaugeVec
...@@ -284,6 +284,15 @@ func NewMetrics(procName string) *Metrics { ...@@ -284,6 +284,15 @@ func NewMetrics(procName string) *Metrics {
Name: "stream_count", Name: "stream_count",
Help: "Count of currently connected p2p streams", Help: "Count of currently connected p2p streams",
}), }),
PeerScores: factory.NewHistogramVec(prometheus.HistogramOpts{
Namespace: ns,
Subsystem: "p2p",
Name: "peer_scores",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
Help: "Histogram of p2p peer scores",
}, []string{
"method",
}),
GossipEventsTotal: factory.NewCounterVec(prometheus.CounterOpts{ GossipEventsTotal: factory.NewCounterVec(prometheus.CounterOpts{
Namespace: ns, Namespace: ns,
Subsystem: "p2p", Subsystem: "p2p",
...@@ -463,7 +472,7 @@ func (m *Metrics) RecordGossipEvent(evType int32) { ...@@ -463,7 +472,7 @@ func (m *Metrics) RecordGossipEvent(evType int32) {
} }
func (m *Metrics) RecordPeerScoring(peerID peer.ID, score float64) { func (m *Metrics) RecordPeerScoring(peerID peer.ID, score float64) {
m.PeerScores[peerID] = score m.PeerScores.WithLabelValues(peerID.String()).Observe(score)
} }
func (m *Metrics) IncPeerCount() { func (m *Metrics) IncPeerCount() {
......
...@@ -29,9 +29,9 @@ func NewPeerScoreParams() pubsub.PeerScoreParams { ...@@ -29,9 +29,9 @@ func NewPeerScoreParams() pubsub.PeerScoreParams {
BehaviourPenaltyWeight: -1, BehaviourPenaltyWeight: -1,
BehaviourPenaltyDecay: 0.999, BehaviourPenaltyDecay: 0.999,
DecayInterval: 24 * time.Hour, DecayInterval: 24 * time.Hour,
DecayToZero: 0.01, DecayToZero: 0.001,
RetainScore: math.MaxInt64, RetainScore: math.MaxInt64, // We want to keep scores indefinitely - don't refresh on connect/disconnect
SeenMsgTTL: 0, // Defaults to global TimeCacheDuration when 0 SeenMsgTTL: 0, // Defaults to global TimeCacheDuration when 0
} }
} }
......
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