Tag message metrics by type

This commit is contained in:
Jack Grigg 2021-03-14 15:56:13 +13:00 committed by teor
parent bae9a7ecd5
commit 7a8cae9321
1 changed files with 8 additions and 4 deletions

View File

@ -363,8 +363,12 @@ where
let peer_tx = peer_tx.with(move |msg: Message| { let peer_tx = peer_tx.with(move |msg: Message| {
// Add a metric for outbound messages. // Add a metric for outbound messages.
// XXX add a dimension tagging message metrics by type metrics::counter!(
metrics::counter!("zcash.net.out.messages", 1, "addr" => addr.to_string()); "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, // We need to use future::ready rather than an async block here,
// because we need the sink to be Unpin, and the With<Fut, ...> // because we need the sink to be Unpin, and the With<Fut, ...>
// returned by .with is Unpin only if Fut is Unpin, and the // 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. // Add a metric for inbound messages and fire a timestamp event.
let mut timestamp_collector = timestamp_collector.clone(); let mut timestamp_collector = timestamp_collector.clone();
async move { async move {
if msg.is_ok() { if let Ok(msg) = &msg {
// XXX add a dimension tagging message metrics by type
metrics::counter!( metrics::counter!(
"zcash.net.in.messages", "zcash.net.in.messages",
1, 1,
"command" => msg.to_string(),
"addr" => addr.to_string(), "addr" => addr.to_string(),
); );
use futures::sink::SinkExt; use futures::sink::SinkExt;