Skip to content

Commit 3fb9e92

Browse files
committed
metrics/service: Add background_jobs metric
1 parent 143f698 commit 3fb9e92

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/metrics/service.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! As a rule of thumb, if the metric is not straight up fetched from the database it's probably an
1111
//! instance-level metric, and you should add it to `src/metrics/instance.rs`.
1212
13-
use crate::schema::{crates, versions};
13+
use crate::schema::{background_jobs, crates, versions};
1414
use crate::util::errors::AppResult;
1515
use diesel::{dsl::count_star, prelude::*, PgConnection};
1616
use prometheus::{proto::MetricFamily, IntGauge};
@@ -21,6 +21,8 @@ metrics! {
2121
crates_total: IntGauge,
2222
/// Number of versions ever published
2323
versions_total: IntGauge,
24+
/// Number of queued up background jobs
25+
background_jobs: IntGauge,
2426
}
2527

2628
// All service metrics will be prefixed with this namespace.
@@ -33,6 +35,8 @@ impl ServiceMetrics {
3335
.set(crates::table.select(count_star()).first(conn)?);
3436
self.versions_total
3537
.set(versions::table.select(count_star()).first(conn)?);
38+
self.background_jobs
39+
.set(background_jobs::table.select(count_star()).first(conn)?);
3640

3741
Ok(self.registry.gather())
3842
}

0 commit comments

Comments
 (0)