From e75b23a43c1f1995162c6959ee393be709b60279 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 4 Jun 2020 12:49:38 +0200 Subject: [PATCH 1/2] metrics: fix docsrs_prioritized_crates_count The metric was including failed crates, and didn't consider that the priority is stored with the wrong sign in the database (a positive priority means a negative priority, for whatever reason). --- src/web/metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/metrics.rs b/src/web/metrics.rs index ac4e17a44..b8a041dd3 100644 --- a/src/web/metrics.rs +++ b/src/web/metrics.rs @@ -124,7 +124,7 @@ pub fn metrics_handler(req: &mut Request) -> IronResult { .get(0), ); PRIORITIZED_CRATES_COUNT.set( - ctry!(conn.query("SELECT COUNT(*) FROM queue WHERE priority >= 0;", &[])) + ctry!(conn.query("SELECT COUNT(*) FROM queue WHERE attempts < 5 AND priority <= 0;", &[])) .get(0) .get(0), ); From 333d32fe4b3df2da32828dbfb5d6bb3cbc6b3405 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 11 Jun 2020 14:58:25 +0200 Subject: [PATCH 2/2] Update src/web/metrics.rs Co-authored-by: Joshua Nelson --- src/web/metrics.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/web/metrics.rs b/src/web/metrics.rs index b8a041dd3..6a7cde280 100644 --- a/src/web/metrics.rs +++ b/src/web/metrics.rs @@ -124,9 +124,12 @@ pub fn metrics_handler(req: &mut Request) -> IronResult { .get(0), ); PRIORITIZED_CRATES_COUNT.set( - ctry!(conn.query("SELECT COUNT(*) FROM queue WHERE attempts < 5 AND priority <= 0;", &[])) - .get(0) - .get(0), + ctry!(conn.query( + "SELECT COUNT(*) FROM queue WHERE attempts < 5 AND priority <= 0;", + &[] + )) + .get(0) + .get(0), ); FAILED_CRATES_COUNT.set( ctry!(conn.query("SELECT COUNT(*) FROM queue WHERE attempt >= 5;", &[]))