Skip to content
This repository was archived by the owner on Jun 21, 2024. It is now read-only.

Commit c856730

Browse files
authored
Add histogram for insertion time to completion time (#5)
* Add histogram for insertion time to completion time * Handle feedback * Oops, spurious import
1 parent f9626e9 commit c856730

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hook-worker/src/worker.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections;
22
use std::sync::Arc;
33
use std::time;
44

5+
use chrono::Utc;
56
use futures::future::join_all;
67
use hook_common::health::HealthHandle;
78
use hook_common::pgqueue::PgTransactionBatch;
@@ -234,11 +235,24 @@ async fn process_webhook_job<W: WebhookJob>(
234235

235236
match send_result {
236237
Ok(_) => {
238+
let created_at = webhook_job.job().created_at;
239+
let retries = webhook_job.job().attempt - 1;
240+
let labels_with_retries = [
241+
("queue", webhook_job.queue()),
242+
("retries", retries.to_string()),
243+
];
244+
237245
webhook_job.complete().await.map_err(|error| {
238246
metrics::counter!("webhook_jobs_database_error", &labels).increment(1);
239247
error
240248
})?;
241249

250+
let insert_to_complete_duration = Utc::now() - created_at;
251+
metrics::histogram!(
252+
"webhook_jobs_insert_to_complete_duration_seconds",
253+
&labels_with_retries
254+
)
255+
.record((insert_to_complete_duration.num_milliseconds() as f64) / 1_000_f64);
242256
metrics::counter!("webhook_jobs_completed", &labels).increment(1);
243257
metrics::histogram!("webhook_jobs_processing_duration_seconds", &labels)
244258
.record(elapsed);

0 commit comments

Comments
 (0)