Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
fix(metric): network broadcast all data size (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroqn authored Sep 10, 2020
1 parent 31d66ab commit 5a8999a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/network/src/peer_manager/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ impl SharedSessionBook for SharedSessions {
.collect()
})
}

fn len(&self) -> usize {
self.sessions().len()
}
}

#[cfg(test)]
Expand Down
5 changes: 1 addition & 4 deletions core/network/src/protocols/transmitter/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ impl<'a> SendingContext<'a> {
let data_size = match &target {
TargetSession::Single(_) => data.len(),
TargetSession::Multi(sessions) => data.len().saturating_mul(sessions.len()),
_ => {
log::warn!("filter blocked return target other than single and multi");
data.len()
}
TargetSession::All => data.len().saturating_mul(self.sessions.len()),
};
common_apm::metrics::network::NETWORK_MESSAGE_SIZE_COUNT_VEC
.with_label_values(&["send", url])
Expand Down
1 change: 1 addition & 0 deletions core/network/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub trait SharedSessionBook {
fn connected_addr(&self, sid: SessionId) -> Option<ConnectedAddr>;
fn pending_data_size(&self, sid: SessionId) -> usize;
fn allowlist(&self) -> Vec<PeerId>;
fn len(&self) -> usize;
}

pub trait MultiaddrExt {
Expand Down

0 comments on commit 5a8999a

Please sign in to comment.