revise metrics naming

This commit is contained in:
Astro 2022-12-20 04:10:45 +01:00
parent 0f1a8fb546
commit 249764acae
4 changed files with 11 additions and 12 deletions

View file

@ -62,7 +62,7 @@ impl Database {
self.inner.client.execute(&self.inner.add_follow, &[&id, &inbox, &actor]) self.inner.client.execute(&self.inner.add_follow, &[&id, &inbox, &actor])
.await?; .await?;
let t2 = Instant::now(); let t2 = Instant::now();
histogram!("sql", t2 - t1, "query" => "add_follow"); histogram!("postgres_query_duration", t2 - t1, "query" => "add_follow");
Ok(()) Ok(())
} }
@ -71,7 +71,7 @@ impl Database {
self.inner.client.execute(&self.inner.del_follow, &[&id, &actor]) self.inner.client.execute(&self.inner.del_follow, &[&id, &actor])
.await?; .await?;
let t2 = Instant::now(); let t2 = Instant::now();
histogram!("sql", t2 - t1, "query" => "del_follow"); histogram!("postgres_query_duration", t2 - t1, "query" => "del_follow");
Ok(()) Ok(())
} }
@ -80,7 +80,7 @@ impl Database {
let rows = self.inner.client.query(&self.inner.get_following_inboxes, &[&actor]) let rows = self.inner.client.query(&self.inner.get_following_inboxes, &[&actor])
.await?; .await?;
let t2 = Instant::now(); let t2 = Instant::now();
histogram!("sql", t2 - t1, "query" => "get_following_inboxes"); histogram!("postgres_query_duration", t2 - t1, "query" => "get_following_inboxes");
Ok(rows.into_iter() Ok(rows.into_iter()
.map(|row| row.get(0)) .map(|row| row.get(0))
) )

View file

@ -42,7 +42,7 @@ impl FromRef<State> for Arc<reqwest::Client> {
} }
fn track_request(method: &'static str, controller: &'static str, result: &'static str) { fn track_request(method: &'static str, controller: &'static str, result: &'static str) {
increment_counter!("request", "controller" => controller, "method" => method, "result" => result); increment_counter!("api_http_requests_total", "controller" => controller, "method" => method, "result" => result);
} }
async fn webfinger( async fn webfinger(

View file

@ -84,7 +84,7 @@ pub fn spawn(
Some(url) => url, Some(url) => url,
// skip reposts // skip reposts
None => { None => {
increment_counter!("post", "action" => "skip"); increment_counter!("relay_posts_total", "action" => "skip");
continue; continue;
} }
}; };
@ -119,7 +119,6 @@ pub fn spawn(
let private_key_ = private_key.clone(); let private_key_ = private_key.clone();
tracing::debug!("relay {} from {} to {}", &post_url, actor_id, inbox); tracing::debug!("relay {} from {} to {}", &post_url, actor_id, inbox);
tokio::spawn(async move { tokio::spawn(async move {
increment_counter!("relay", "target" => inbox.clone());
if let Err(e) = send::send_raw( if let Err(e) = send::send_raw(
&client_, &inbox, &client_, &inbox,
&key_id, &private_key_, body_ &key_id, &private_key_, body_
@ -139,12 +138,12 @@ pub fn spawn(
seen_actors.insert(actor); seen_actors.insert(actor);
} }
if seen_inboxes.is_empty() { if seen_inboxes.is_empty() {
increment_counter!("post", "action" => "no_relay"); increment_counter!("relay_posts_total", "action" => "no_relay");
} else { } else {
increment_counter!("post", "action" => "relay"); increment_counter!("relay_posts_total", "action" => "relay");
} }
let t2 = Instant::now(); let t2 = Instant::now();
histogram!("relay_post", t2 - t1); histogram!("relay_post_duration", t2 - t1);
} }
}); });
} }

View file

@ -81,12 +81,12 @@ pub async fn send_raw(
let res = client.execute(req) let res = client.execute(req)
.await?; .await?;
let t3 = Instant::now(); let t3 = Instant::now();
histogram!("sign_req", t2 - t1); histogram!("relay_http_request_duration", t2 - t1);
if res.status() >= StatusCode::OK && res.status() < StatusCode::MULTIPLE_CHOICES { if res.status() >= StatusCode::OK && res.status() < StatusCode::MULTIPLE_CHOICES {
histogram!("req", t3 - t2, "res" => "ok", "host" => host); histogram!("relay_http_response_duration", t3 - t2, "res" => "ok", "host" => host);
Ok(()) Ok(())
} else { } else {
histogram!("req", t3 - t2, "res" => "err", "host" => host); histogram!("relay_http_response_duration", t3 - t2, "res" => "err", "host" => host);
let response = res.text().await?; let response = res.text().await?;
Err(SendError::Response(response)) Err(SendError::Response(response))
} }