Skip to content

Commit

Permalink
Alter the logic how peer identities are recorded
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-ssvlabs committed Dec 2, 2024
1 parent b9c7af3 commit 73b6b24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion network/p2p/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func recordPeerCountPerTopic(ctx context.Context, ctrl topics.Controller) func()

func recordPeerIdentities(ctx context.Context, peers []peer.ID, index peers.Index) func() {
return func() {
peersByVersion := make(map[string]int64)
for _, pid := range peers {
nodeVersion := "unknown"
ni := index.NodeInfo(pid)
Expand All @@ -73,7 +74,10 @@ func recordPeerIdentities(ctx context.Context, peers []peer.ID, index peers.Inde
nodeVersion = ni.Metadata.NodeVersion
}
}
peerIdentityGauge.Record(ctx, 1, metric.WithAttributes(attribute.String("ssv.node.version", nodeVersion)))
peersByVersion[nodeVersion]++
}
for version, peerCount := range peersByVersion {
peerIdentityGauge.Record(ctx, peerCount, metric.WithAttributes(attribute.String("ssv.node.version", version)))
}
}
}

0 comments on commit 73b6b24

Please sign in to comment.