From 621df0f2834f344f214d3c7f182e498fbd2e2ef1 Mon Sep 17 00:00:00 2001 From: Brett Hoerner Date: Tue, 6 Feb 2024 08:04:51 -0700 Subject: [PATCH] Add histogram for insertion time to completion time --- hook-worker/src/worker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hook-worker/src/worker.rs b/hook-worker/src/worker.rs index 484edf7..ebb1b0f 100644 --- a/hook-worker/src/worker.rs +++ b/hook-worker/src/worker.rs @@ -2,6 +2,7 @@ use std::collections; use std::sync::Arc; use std::time; +use chrono::Utc; use futures::future::join_all; use hook_common::health::HealthHandle; use hook_common::pgqueue::PgTransactionBatch; @@ -234,6 +235,10 @@ async fn process_webhook_job( match send_result { Ok(_) => { + let insert_to_complete_duration = Utc::now() - webhook_job.job().created_at; + metrics::histogram!("webhook_jobs_insert_to_complete_duration_seconds", &labels) + .record((insert_to_complete_duration.num_milliseconds() as f64) / 1_000_f64); + webhook_job.complete().await.map_err(|error| { metrics::counter!("webhook_jobs_database_error", &labels).increment(1); error