mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-25 05:20:59 +00:00
relay: add histogram "relay_post"
This commit is contained in:
parent
a3847e20b2
commit
959c5c41b2
1 changed files with 5 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue