Skip to content
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

network: introduce near_peer_message_sent_by_type_{bytes,total} metrics #7523

Merged
merged 2 commits into from
Sep 1, 2022
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
deprecated. In fact it has never been used and only served to
confuse everyone [#7300](https://github.com/near/nearcore/pull/7300)
* Due to increasing state size, improved shard cache for Trie nodes to
put more nodes in memory. Requires 3 GB more RAM
put more nodes in memory. Requires 3 GB more RAM
[#7429](https://github.com/near/nearcore/pull/7429)
* Added `near_peer_message_sent_by_type_bytes` and
`near_peer_message_sent_by_type_total` Prometheus metrics measuring
size and number of messages sent to peers.

## 1.28.0 [2022-07-27]

Expand Down
8 changes: 6 additions & 2 deletions chain/network/src/peer/peer_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl PeerActor {
msg: &PeerMessage,
enc: Encoding,
) -> Result<(), IOError> {
let msg_type: &str = msg.into();
let msg_type: &str = msg.msg_variant();
let _span = tracing::trace_span!(
target: "network",
"send_message_with_encoding",
Expand All @@ -232,14 +232,18 @@ impl PeerActor {
self.tracker.lock().increment_sent(&self.clock, bytes.len() as u64);
let bytes_len = bytes.len();
tracing::trace!(target: "network", msg_len = bytes_len);
metrics::PEER_DATA_SENT_BYTES.inc_by(bytes_len as u64);
if !self.framed.write(bytes) {
#[cfg(feature = "performance_stats")]
let tid = near_rust_allocator_proxy::get_tid();
#[cfg(not(feature = "performance_stats"))]
let tid = 0;
return Err(IOError::Send { tid, message_type: msg_type.to_string(), size: bytes_len });
}
metrics::PEER_DATA_SENT_BYTES.inc_by(bytes_len as u64);
metrics::PEER_MESSAGE_SENT_BY_TYPE_TOTAL.with_label_values(&[msg_type]).inc();
metrics::PEER_MESSAGE_SENT_BY_TYPE_BYTES
.with_label_values(&[msg_type])
.inc_by(bytes_len as u64);
Ok(())
}

Expand Down
18 changes: 17 additions & 1 deletion chain/network/src/stats/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ pub(crate) static PEER_MESSAGE_RECEIVED_TOTAL: Lazy<IntCounter> = Lazy::new(|| {
pub(crate) static PEER_MESSAGE_RECEIVED_BY_TYPE_TOTAL: Lazy<IntCounterVec> = Lazy::new(|| {
try_create_int_counter_vec(
"near_peer_message_received_by_type_total",
"Number of messages received from peers, by message types",
"Number of messages received from peers by message types",
&["type"],
)
.unwrap()
});
pub(crate) static PEER_MESSAGE_SENT_BY_TYPE_BYTES: Lazy<IntCounterVec> = Lazy::new(|| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fun of _BY_TYPE but seems consistent with existing metrics.

try_create_int_counter_vec(
"near_peer_message_sent_by_type_bytes",
"Total data sent to peers by message types",
&["type"],
)
.unwrap()
});
pub(crate) static PEER_MESSAGE_SENT_BY_TYPE_TOTAL: Lazy<IntCounterVec> = Lazy::new(|| {
try_create_int_counter_vec(
"near_peer_message_sent_by_type_total",
"Number of messages sent to peers by message types",
&["type"],
)
.unwrap()
Expand Down