Skip to content

Commit

Permalink
update dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Feb 23, 2023
1 parent a8d7b02 commit 123f806
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Metrics were added to:
- [IP Version](https://github.com/libp2p/go-libp2p/pull/2114): Added ip_version label to connection metrics
* Identify:
- Metrics for Identify, IdentifyPush, PushesTriggered (https://github.com/libp2p/go-libp2p/pull/2069)
- Address Count, Protocol Count, Peer Protocol Support (https://github.com/libp2p/go-libp2p/pull/2126)
- Address Count, Protocol Count, Connection IDPush Support (https://github.com/libp2p/go-libp2p/pull/2126)


## 🐞 Bugfixes <!-- omit in toc -->
Expand Down
6 changes: 3 additions & 3 deletions dashboards/identify/identify.json
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,13 @@
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "increase(libp2p_identify_peer_push_support_total[$__rate_interval])",
"expr": "increase(libp2p_identify_conn_push_support_total[$__rate_interval])",
"legendFormat": "{{support}}",
"range": true,
"refId": "A"
}
],
"title": "New Peers: Push Support",
"title": "New Connections: Push Support",
"type": "piechart"
}
],
Expand All @@ -847,6 +847,6 @@
"timezone": "",
"title": "libp2p Identify",
"uid": "0NDzQQ0Vz",
"version": 7,
"version": 2,
"weekStart": ""
}
2 changes: 1 addition & 1 deletion p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (ids *idService) handleIdentifyResponse(s network.Stream, isPush bool) erro
}

if ids.metricsTracer != nil {
ids.metricsTracer.PeerPushSupport(e.PushSupport)
ids.metricsTracer.ConnPushSupport(e.PushSupport)
}

ids.conns[c] = e
Expand Down
18 changes: 9 additions & 9 deletions p2p/protocol/identify/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ var (
},
[]string{"dir"},
)
peerPushSupport = prometheus.NewCounterVec(
connPushSupportTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: metricNamespace,
Name: "peer_push_support_total",
Help: "Identify Peer Push Support",
Name: "conn_push_support_total",
Help: "Identify Connection Push Support",
},
[]string{"support"},
)
Expand Down Expand Up @@ -77,7 +77,7 @@ var (
pushesTriggered,
identify,
identifyPush,
peerPushSupport,
connPushSupportTotal,
protocolsCount,
addrsCount,
numProtocolsReceived,
Expand All @@ -94,8 +94,8 @@ type MetricsTracer interface {
// TriggeredPushes counts IdentifyPushes triggered by event
TriggeredPushes(event any)

// PeerPushSupport counts peers by Push Support
PeerPushSupport(identifyPushSupport)
// ConnPushSupport counts peers by Push Support
ConnPushSupport(identifyPushSupport)

// IdentifyReceived tracks metrics on receiving an identify response
IdentifyReceived(isPush bool, numProtocols int, numAddrs int)
Expand Down Expand Up @@ -151,7 +151,7 @@ func (t *metricsTracer) IncrementPushSupport(s identifyPushSupport) {
defer metricshelper.PutStringSlice(tags)

*tags = append(*tags, getPushSupport(s))
peerPushSupport.WithLabelValues(*tags...).Inc()
connPushSupportTotal.WithLabelValues(*tags...).Inc()
}

func (t *metricsTracer) IdentifySent(isPush bool, numProtocols int, numAddrs int) {
Expand Down Expand Up @@ -186,12 +186,12 @@ func (t *metricsTracer) IdentifyReceived(isPush bool, numProtocols int, numAddrs
numAddrsReceived.Observe(float64(numAddrs))
}

func (t *metricsTracer) PeerPushSupport(support identifyPushSupport) {
func (t *metricsTracer) ConnPushSupport(support identifyPushSupport) {
tags := metricshelper.GetStringSlice()
defer metricshelper.PutStringSlice(tags)

*tags = append(*tags, getPushSupport(support))
peerPushSupport.WithLabelValues(*tags...).Inc()
connPushSupportTotal.WithLabelValues(*tags...).Inc()
}

func getPushSupport(s identifyPushSupport) string {
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/identify/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestMetricsNoAllocNoCover(t *testing.T) {
tr := NewMetricsTracer()
tests := map[string]func(){
"TriggeredPushes": func() { tr.TriggeredPushes(events[rand.Intn(len(events))]) },
"PeerPushSupport": func() { tr.PeerPushSupport(pushSupport[rand.Intn(len(pushSupport))]) },
"ConnPushSupport": func() { tr.ConnPushSupport(pushSupport[rand.Intn(len(pushSupport))]) },
"IdentifyReceived": func() { tr.IdentifyReceived(rand.Intn(2) == 0, rand.Intn(20), rand.Intn(20)) },
"IdentifySent": func() { tr.IdentifySent(rand.Intn(2) == 0, rand.Intn(20), rand.Intn(20)) },
}
Expand Down

0 comments on commit 123f806

Please sign in to comment.