Skip to content

Commit

Permalink
Add p2p.connected_peers.count metric.
Browse files Browse the repository at this point in the history
  • Loading branch information
artemii235 committed Dec 13, 2020
1 parent e3661f3 commit 90db2b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mm2src/lp_native_dex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,16 @@ pub async fn lp_init(mypubport: u16, ctx: MmArc) -> Result<(), String> {
"p2p.received_messages.period_in_secs",
period.as_secs() as i64
);

mm_gauge!(ctx_on_poll.metrics, "p2p.received_messages.count", received_msgs as i64);

let connected_peers_count = swarm.connected_peers_len();

mm_gauge!(
ctx_on_poll.metrics,
"p2p.connected_peers.count",
connected_peers_count as i64
);
},
);
try_s!(ctx.peer_id.pin(peer_id.to_string()));
Expand Down
2 changes: 2 additions & 0 deletions mm2src/mm2_libp2p/src/atomicdex_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ impl AtomicDexBehaviour {
pub fn relay_mesh_len(&self) -> usize { self.gossipsub.relay_mesh_len() }

pub fn received_messages_in_period(&self) -> (Duration, usize) { self.gossipsub.get_received_messages_in_period() }

pub fn connected_peers_len(&self) -> usize { self.gossipsub.get_num_peers() }
}

impl NetworkBehaviourEventProcess<GossipsubEvent> for AtomicDexBehaviour {
Expand Down

0 comments on commit 90db2b0

Please sign in to comment.