diff options
author | iximeow <git@iximeow.net> | 2022-12-29 19:08:01 +0000 |
---|---|---|
committer | iximeow <git@iximeow.net> | 2022-12-29 19:08:01 +0000 |
commit | 0832c96c116f4c3a28bd22a0cdd287a3b0764c7b (patch) | |
tree | 9b58beaf733a7ded11eb8519d37d41653f1e77fe /src/main.rs | |
parent | e28b277980763b88d2828812bff2c0b9546d3d25 (diff) |
record and present metrics
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 21 |
1 files changed, 21 insertions, 0 deletions
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("<div>"); + section.push_str("<h3>metrics</h3>"); + section.push_str("<table style='font-family: monospace;'>"); + section.push_str("<tr><th>name</th><th>value</th></tr>"); + for metric in metrics { + section.push_str(&format!("<tr><td>{}</td><td>{}</td></tr>", &metric.name, &metric.value)); + } + section.push_str("</table>"); + section.push_str("</div>"); + Some(section) + } else { + None + }; + let mut html = String::new(); html.push_str("<html>\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(" <div>last build output</div>\n"); html.push_str(&format!(" {}\n", output)); } + if let Some(metrics) = metrics_section { + html.push_str(&metrics); + } html.push_str(" </body>\n"); html.push_str("</html>"); |