From 0832c96c116f4c3a28bd22a0cdd287a3b0764c7b Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 29 Dec 2022 19:08:01 +0000 Subject: record and present metrics --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index a96c5e4..f14b325 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use hmac::{Hmac, Mac}; use sha2::Sha256; +mod io; mod sql; mod notifier; mod dbctx; @@ -245,6 +246,23 @@ async fn handle_commit_status(Path(path): Path<(String, String, String)>, State( None }; + let metrics = ctx.metrics_for_job(job_id).unwrap(); + let metrics_section = if metrics.len() > 0 { + let mut section = String::new(); + section.push_str("
"); + section.push_str("

metrics

"); + section.push_str(""); + section.push_str(""); + for metric in metrics { + section.push_str(&format!("", &metric.name, &metric.value)); + } + section.push_str("
namevalue
{}{}
"); + section.push_str("
"); + Some(section) + } else { + None + }; + let mut html = String::new(); html.push_str("\n"); html.push_str(&format!(" {}\n", head)); @@ -262,6 +280,9 @@ async fn handle_commit_status(Path(path): Path<(String, String, String)>, State( html.push_str("
last build output
\n"); html.push_str(&format!(" {}\n", output)); } + if let Some(metrics) = metrics_section { + html.push_str(&metrics); + } html.push_str(" \n"); html.push_str(""); -- cgit v1.1