Tag message metrics by type
@@ -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<Fut, ...>
// 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;
