Skip to content

Commit afc6917

Browse files
Add metrics for duration of individual steps in the last collection
1 parent f9bcd17 commit afc6917

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

site/src/server.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,16 +1462,38 @@ impl Server {
14621462
async fn handle_metrics(&self, _req: Request) -> Response {
14631463
use prometheus::Encoder;
14641464
let data: Arc<InputData> = self.data.read().as_ref().unwrap().clone();
1465+
let idx = data.index.load();
14651466

14661467
let mut buffer = Vec::new();
14671468
let r = prometheus::Registry::new();
14681469

14691470
let queue_length =
14701471
prometheus::IntGauge::new("rustc_perf_queue_length", "queue length").unwrap();
14711472
queue_length.set(data.missing_commits().await.len() as i64);
1472-
14731473
r.register(Box::new(queue_length)).unwrap();
14741474

1475+
if let Some(last_commit) = idx.commits().last().cloned() {
1476+
let conn = data.conn().await;
1477+
let steps = conn.in_progress_steps(&ArtifactId::from(last_commit)).await;
1478+
let g = prometheus::IntGaugeVec::new(
1479+
prometheus::core::Opts {
1480+
namespace: format!("rustc_perf"),
1481+
subsystem: String::new(),
1482+
name: String::from("step_duration_seconds"),
1483+
help: String::from("step duration"),
1484+
const_labels: HashMap::new(),
1485+
variable_labels: vec![],
1486+
},
1487+
&["step"],
1488+
)
1489+
.unwrap();
1490+
for step in steps {
1491+
g.with_label_values(&[&step.name])
1492+
.set(step.expected.as_secs() as i64);
1493+
}
1494+
r.register(Box::new(g)).unwrap();
1495+
}
1496+
14751497
let encoder = prometheus::TextEncoder::new();
14761498
let metric_families = r.gather();
14771499
encoder.encode(&metric_families, &mut buffer).unwrap();

0 commit comments

Comments
 (0)