-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(metrics): expose connected_peers, peers_in_rt and uptime metrics #1896
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6447aa9
feat(metrics): expose the number of connected peers
RolandSherwin 81b0c50
feat(metrics): expose the total number of peers in the routing table
RolandSherwin 1d993a7
feat(metrics): expose the uptime of the node
RolandSherwin d96cbbb
fix(network): update state once bootstrap node has been replaced
RolandSherwin da04ce3
feat(metrics): expose open_connections separately
RolandSherwin cb96c8f
chore: warn if our peer tracking goes out of sync
RolandSherwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
use crate::{ | ||
driver::PendingGetClosestType, get_quorum_value, GetRecordCfg, GetRecordError, NetworkError, | ||
NetworkEvent, Result, SwarmDriver, CLOSE_GROUP_SIZE, | ||
Result, SwarmDriver, CLOSE_GROUP_SIZE, | ||
}; | ||
use itertools::Itertools; | ||
use libp2p::kad::{ | ||
|
@@ -245,26 +245,19 @@ impl SwarmDriver { | |
} => { | ||
event_string = "kad_event::RoutingUpdated"; | ||
if is_new_peer { | ||
self.connected_peers = self.connected_peers.saturating_add(1); | ||
|
||
info!("New peer added to routing table: {peer:?}, now we have #{} connected peers", self.connected_peers); | ||
self.log_kbuckets(&peer); | ||
self.update_on_peer_addition(peer); | ||
|
||
// This should only happen once | ||
if self.bootstrap.notify_new_peer() { | ||
info!("Performing the first bootstrap"); | ||
self.trigger_network_discovery(); | ||
} | ||
self.send_event(NetworkEvent::PeerAdded(peer, self.connected_peers)); | ||
} | ||
|
||
info!("kad_event::RoutingUpdated {:?}: {peer:?}, is_new_peer: {is_new_peer:?} old_peer: {old_peer:?}", self.connected_peers); | ||
if old_peer.is_some() { | ||
self.connected_peers = self.connected_peers.saturating_sub(1); | ||
|
||
info!("kad_event::RoutingUpdated {:?}: {peer:?}, is_new_peer: {is_new_peer:?} old_peer: {old_peer:?}", self.peers_in_rt); | ||
if let Some(old_peer) = old_peer { | ||
info!("Evicted old peer on new peer join: {old_peer:?}"); | ||
self.send_event(NetworkEvent::PeerRemoved(peer, self.connected_peers)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were supposed to emit |
||
self.log_kbuckets(&peer); | ||
self.update_on_peer_removal(old_peer); | ||
} | ||
let _ = self.check_for_change_in_our_close_group(); | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tracks the total number of peers in the RT rather than the "connections". So renamed it for clarity.