mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-22 04:00:59 +00:00
revise metrics naming
This commit is contained in:
parent
0f1a8fb546
commit
249764acae
4 changed files with 11 additions and 12 deletions
|
@ -62,7 +62,7 @@ impl Database {
|
|||
self.inner.client.execute(&self.inner.add_follow, &[&id, &inbox, &actor])
|
||||
.await?;
|
||||
let t2 = Instant::now();
|
||||
histogram!("sql", t2 - t1, "query" => "add_follow");
|
||||
histogram!("postgres_query_duration", t2 - t1, "query" => "add_follow");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl Database {
|
|||
self.inner.client.execute(&self.inner.del_follow, &[&id, &actor])
|
||||
.await?;
|
||||
let t2 = Instant::now();
|
||||
histogram!("sql", t2 - t1, "query" => "del_follow");
|
||||
histogram!("postgres_query_duration", t2 - t1, "query" => "del_follow");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ impl Database {
|
|||
let rows = self.inner.client.query(&self.inner.get_following_inboxes, &[&actor])
|
||||
.await?;
|
||||
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()
|
||||
.map(|row| row.get(0))
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ impl FromRef<State> for Arc<reqwest::Client> {
|
|||
}
|
||||
|
||||
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(
|
||||
|
|
|
@ -84,7 +84,7 @@ pub fn spawn(
|
|||
Some(url) => url,
|
||||
// skip reposts
|
||||
None => {
|
||||
increment_counter!("post", "action" => "skip");
|
||||
increment_counter!("relay_posts_total", "action" => "skip");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -119,7 +119,6 @@ pub fn spawn(
|
|||
let private_key_ = private_key.clone();
|
||||
tracing::debug!("relay {} from {} to {}", &post_url, actor_id, inbox);
|
||||
tokio::spawn(async move {
|
||||
increment_counter!("relay", "target" => inbox.clone());
|
||||
if let Err(e) = send::send_raw(
|
||||
&client_, &inbox,
|
||||
&key_id, &private_key_, body_
|
||||
|
@ -139,12 +138,12 @@ pub fn spawn(
|
|||
seen_actors.insert(actor);
|
||||
}
|
||||
if seen_inboxes.is_empty() {
|
||||
increment_counter!("post", "action" => "no_relay");
|
||||
increment_counter!("relay_posts_total", "action" => "no_relay");
|
||||
} else {
|
||||
increment_counter!("post", "action" => "relay");
|
||||
increment_counter!("relay_posts_total", "action" => "relay");
|
||||
}
|
||||
let t2 = Instant::now();
|
||||
histogram!("relay_post", t2 - t1);
|
||||
histogram!("relay_post_duration", t2 - t1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -81,12 +81,12 @@ pub async fn send_raw(
|
|||
let res = client.execute(req)
|
||||
.await?;
|
||||
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 {
|
||||
histogram!("req", t3 - t2, "res" => "ok", "host" => host);
|
||||
histogram!("relay_http_response_duration", t3 - t2, "res" => "ok", "host" => host);
|
||||
Ok(())
|
||||
} 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?;
|
||||
Err(SendError::Response(response))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue