20260803 死repo传输层黑名单+daemon健康检查摘除(#141)
This commit is contained in:
@@ -433,6 +433,8 @@ struct LatestRunMetrics {
|
||||
download_bytes: Option<u64>,
|
||||
artifact_sizes: BTreeMap<String, u64>,
|
||||
state_path_sizes: BTreeMap<String, PathSize>,
|
||||
dead_repo_blacklist_entries: Option<u64>,
|
||||
dead_repo_blacklist_blacklisted: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize)]
|
||||
@@ -1377,6 +1379,10 @@ fn build_latest_metrics(record: &RunRecord, snapshot: &mut MetricsSnapshot) {
|
||||
latest.download_bytes = json_u64(summary, &["stageTiming", "download_bytes_total"]);
|
||||
latest.artifact_sizes = extract_artifact_sizes(summary.get("artifacts"));
|
||||
latest.state_path_sizes = extract_path_sizes(summary.get("pathStats"));
|
||||
latest.dead_repo_blacklist_entries =
|
||||
json_u64(summary, &["deadRepoBlacklist", "entries"]);
|
||||
latest.dead_repo_blacklist_blacklisted =
|
||||
json_u64(summary, &["deadRepoBlacklist", "blacklisted"]);
|
||||
}
|
||||
|
||||
parse_report(&record.path.join("report.json"), snapshot, &mut latest);
|
||||
@@ -2419,6 +2425,22 @@ fn render_latest_metrics(writer: &mut PromWriter<'_>, instance: &str, latest: &L
|
||||
value as f64,
|
||||
);
|
||||
}
|
||||
if let Some(value) = latest.dead_repo_blacklist_entries {
|
||||
writer.gauge(
|
||||
"ours_rp_dead_repo_blacklist_entries",
|
||||
"Dead-repo transport blacklist entries (latest run)",
|
||||
&[label("instance", instance), label("state", "total")],
|
||||
value as f64,
|
||||
);
|
||||
}
|
||||
if let Some(value) = latest.dead_repo_blacklist_blacklisted {
|
||||
writer.gauge(
|
||||
"ours_rp_dead_repo_blacklist_entries",
|
||||
"Dead-repo transport blacklist entries (latest run)",
|
||||
&[label("instance", instance), label("state", "blacklisted")],
|
||||
value as f64,
|
||||
);
|
||||
}
|
||||
for (stage, value) in &latest.stage_seconds {
|
||||
writer.gauge(
|
||||
"ours_rp_run_stage_duration_seconds",
|
||||
@@ -3893,4 +3915,37 @@ mod tests {
|
||||
});
|
||||
encode_content_info(&ci).expect("encode ccr")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dead_repo_blacklist_gauges_render_from_latest_summary() {
|
||||
let td = TempDir::new().expect("tempdir");
|
||||
write_success_run(td.path(), "run_0001", 1);
|
||||
// Rewrite the summary with the blacklist section present.
|
||||
let run = td.path().join("runs").join("run_0001");
|
||||
fs::write(
|
||||
run.join("run-summary.json"),
|
||||
r#"{"runSeq":1,"runId":"run_0001","startedAtRfc3339Utc":"2026-07-21T00:00:00Z","finishedAtRfc3339Utc":"2026-07-21T00:00:10Z","wallMs":10000,"status":"success","exitCode":0,"deadRepoBlacklist":{"path":"/state/dead-repo-blacklist.json","entries":5,"blacklisted":3}}"#,
|
||||
)
|
||||
.expect("summary");
|
||||
let snapshot = scan_run_root(td.path(), "test").expect("scan");
|
||||
let latest = snapshot.latest_run.as_ref().expect("latest run");
|
||||
assert_eq!(latest.dead_repo_blacklist_entries, Some(5));
|
||||
assert_eq!(latest.dead_repo_blacklist_blacklisted, Some(3));
|
||||
let metrics = render_metrics(&snapshot);
|
||||
assert!(metrics.contains(
|
||||
r#"ours_rp_dead_repo_blacklist_entries{instance="test",state="total"} 5"#
|
||||
));
|
||||
assert!(metrics.contains(
|
||||
r#"ours_rp_dead_repo_blacklist_entries{instance="test",state="blacklisted"} 3"#
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dead_repo_blacklist_gauges_absent_without_section() {
|
||||
let td = TempDir::new().expect("tempdir");
|
||||
write_success_run(td.path(), "run_0001", 1);
|
||||
let snapshot = scan_run_root(td.path(), "test").expect("scan");
|
||||
let metrics = render_metrics(&snapshot);
|
||||
assert!(!metrics.contains("ours_rp_dead_repo_blacklist_entries"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user