From 959c5c41b2e44cd39dadc1da62b83434a6241e61 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 20 Dec 2022 03:59:32 +0100 Subject: [PATCH] relay: add histogram "relay_post" --- src/relay.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/relay.rs b/src/relay.rs index e9b61b3..4a6ff94 100644 --- a/src/relay.rs +++ b/src/relay.rs @@ -1,5 +1,5 @@ -use std::{sync::Arc, collections::HashSet}; -use metrics::increment_counter; +use std::{sync::Arc, collections::HashSet, time::Instant}; +use metrics::{increment_counter, histogram}; use serde::Deserialize; use serde_json::json; use sigh::PrivateKey; @@ -71,7 +71,7 @@ pub fn spawn( tokio::spawn(async move { while let Some(data) = stream_rx.recv().await { - // dbg!(&data); + let t1 = Instant::now(); let post: Post = match serde_json::from_str(&data) { Ok(post) => post, Err(e) => { @@ -80,7 +80,6 @@ pub fn spawn( continue; } }; - // tracing::trace!("post uri={:?} url={:?}", post.uri, post.url); let post_url = match post.url { Some(url) => url, // skip reposts @@ -144,6 +143,8 @@ pub fn spawn( } else { increment_counter!("post", "action" => "relay"); } + let t2 = Instant::now(); + histogram!("relay_post", t2 - t1); } }); }