Add webhook request histogram

This commit is contained in:
Kai Jellinghaus
2023-01-26 07:03:49 +01:00
parent 1e7b7cc8d6
commit 833d0df965
3 changed files with 15 additions and 0 deletions
+2
View File
@@ -4570,8 +4570,10 @@ dependencies = [
"hmac",
"hyper",
"itertools",
"lazy_static",
"magic-crypt",
"mime_guess",
"prometheus",
"rand 0.8.5",
"reqwest",
"retainer",
+2
View File
@@ -70,3 +70,5 @@ cookie.workspace = true
sha2.workspace = true
urlencoding.workspace = true
async-stripe.workspace = true
lazy_static.workspace = true
prometheus.workspace = true
+11
View File
@@ -12,6 +12,15 @@ use tokio::{select, sync::mpsc};
use crate::db::DB;
lazy_static::lazy_static! {
// TODO: these aren't synced, they should be moved into the queue abstraction once/if that happens.
static ref WEBHOOK_REQUEST_COUNT: prometheus::Histogram = prometheus::register_histogram!(
"webhook_request",
"Histogram of webhook requests made"
)
.unwrap();
}
#[derive(Serialize)]
#[serde(tag = "type")]
pub enum WebhookMessage {
@@ -59,7 +68,9 @@ impl WebhookShared {
_ = shutdown_rx.recv() => break,
r = rx.recv() => match r {
Some((url, message)) => {
let timer = WEBHOOK_REQUEST_COUNT.start_timer();
let _ = client.post(url).json(&message).send().await;
timer.stop_and_record();
},
None => break,
}