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

fix(metric): network broadcast all data size #452

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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