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| {
// 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;