diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 8d2405ea80..0919a49eba 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -4570,8 +4570,10 @@ dependencies = [ "hmac", "hyper", "itertools", + "lazy_static", "magic-crypt", "mime_guess", + "prometheus", "rand 0.8.5", "reqwest", "retainer", diff --git a/backend/windmill-api/Cargo.toml b/backend/windmill-api/Cargo.toml index b1d8d6debf..caca339168 100644 --- a/backend/windmill-api/Cargo.toml +++ b/backend/windmill-api/Cargo.toml @@ -70,3 +70,5 @@ cookie.workspace = true sha2.workspace = true urlencoding.workspace = true async-stripe.workspace = true +lazy_static.workspace = true +prometheus.workspace = true diff --git a/backend/windmill-api/src/webhook_util.rs b/backend/windmill-api/src/webhook_util.rs index e94a2f7341..9157f528f5 100644 --- a/backend/windmill-api/src/webhook_util.rs +++ b/backend/windmill-api/src/webhook_util.rs @@ -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, }