From 7a8cae932169834b372897765e6966bd48054b5b Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 14 Mar 2021 15:56:13 +1300 Subject: [PATCH] Tag message metrics by type --- zebra-network/src/peer/handshake.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index 42e33f29..49f1f52c 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -363,8 +363,12 @@ where let peer_tx = peer_tx.with(move |msg: Message| { // Add a metric for outbound messages. - // XXX add a dimension tagging message metrics by type - metrics::counter!("zcash.net.out.messages", 1, "addr" => addr.to_string()); + metrics::counter!( + "zcash.net.out.messages", + 1, + "command" => msg.to_string(), + "addr" => addr.to_string(), + ); // We need to use future::ready rather than an async block here, // because we need the sink to be Unpin, and the With // returned by .with is Unpin only if Fut is Unpin, and the @@ -377,11 +381,11 @@ where // Add a metric for inbound messages and fire a timestamp event. let mut timestamp_collector = timestamp_collector.clone(); async move { - if msg.is_ok() { - // XXX add a dimension tagging message metrics by type + if let Ok(msg) = &msg { metrics::counter!( "zcash.net.in.messages", 1, + "command" => msg.to_string(), "addr" => addr.to_string(), ); use futures::sink::SinkExt;