chore: add client version in metrics#670
Merged
mergify[bot] merged 7 commits intosigp:release-v1.0.0from Oct 10, 2025
Merged
Conversation
Member
|
This is good. I think with #652 I was hoping to add a single endpoint so that we know the version of our current running anchor node so we can display on our dash. Would be nice to add that in too. |
|
This pull request has merge conflicts. Could you please resolve them @petarjuki7? 🙏 |
dknopik
reviewed
Oct 10, 2025
anchor/network/src/network.rs
Outdated
Comment on lines
588
to
634
| let client_type = ClientType::from(metadata.node_version.clone()); | ||
|
|
||
| // Update client type in peer store | ||
| if let Some(peer_info) = store_ref.get_custom_data_mut(&peer_id) { | ||
| peer_info.set_client_type(client_type); | ||
| } else { | ||
| // If no peer info yet, create new peer info | ||
| store_ref.insert_custom_data( | ||
| &peer_id, | ||
| PeerInfo { | ||
| enr: None, | ||
| client_type: Some(client_type), | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| // Record subnet match count | ||
| if let Ok(gauge_vec) = crate::metrics::HANDSHAKE_SUBNET_MATCHES.as_ref() { | ||
| let label = &matching_count.to_string(); | ||
| if let Ok(gauge) = gauge_vec.get_metric_with_label_values(&[label]) { | ||
| gauge.inc(); | ||
| // Count and record matching subnets | ||
| if let Some(our_metadata) = &self.node_info.metadata { | ||
| let matching_count = | ||
| count_matching_subnets(&our_metadata.subnets, &metadata.subnets); | ||
|
|
||
| debug!( | ||
| %peer_id, | ||
| our_subnets = %our_metadata.subnets, | ||
| their_subnets = %metadata.subnets, | ||
| matching_subnets = matching_count, | ||
| "Handshake completed" | ||
| ); | ||
|
|
||
| // Record subnet match count | ||
| if let Ok(gauge_vec) = crate::metrics::HANDSHAKE_SUBNET_MATCHES.as_ref() { | ||
| let label = &matching_count.to_string(); | ||
| if let Ok(gauge) = gauge_vec.get_metric_with_label_values(&[label]) { | ||
| gauge.inc(); | ||
| } | ||
| } | ||
| } else { | ||
| debug!(%peer_id, "Handshake completed"); | ||
| } | ||
|
|
||
| // Trigger metric recalculation | ||
| let behaviour = self.swarm.behaviour(); | ||
| let store_ref = behaviour.peer_manager.peer_store.store(); | ||
| behaviour | ||
| .peer_manager | ||
| .connection_manager | ||
| .update_metrics_if_changed(true, store_ref); |
Member
There was a problem hiding this comment.
Actually, what do you think about moving everything inside this if into the peer manager and/or the connection manager within it? This would allow us to avoid making the peer_store and conncection_manager pub, for better encapsulation
petarjuki7
added a commit
to petarjuki7/anchor
that referenced
this pull request
Oct 16, 2025
Addresses Issue sigp#652 No longer just save `Enr` in `PeerStore`, but a new `PeerInfo` struct which lets us hold its `Enr` and `ClientType` (`Anchor` or `go-ssv`) Then, add metric to count how many `go-ssv` vs `Anchor` nodes are connected to us. Co-Authored-By: petarjuki7 <petar.jukic7@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Addresses Issue #652
Proposed Changes
No longer just save
EnrinPeerStore, but a newPeerInfostruct which lets us hold itsEnrandClientType(Anchororgo-ssv)Then, add metric to count how many
go-ssvvsAnchornodes are connected to us.Additional Info
I expose two fields in the
PeerManagerstruct aspublic(peer_storeandconnection_manager).