update inter-rp repo sync metrics
This commit is contained in:
@@ -258,6 +258,7 @@ struct RepoMetrics {
|
||||
duration_seconds_avg: f64,
|
||||
phase_counts: BTreeMap<String, u64>,
|
||||
terminal_state_counts: BTreeMap<String, u64>,
|
||||
object_counts: BTreeMap<String, u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize)]
|
||||
@@ -859,7 +860,8 @@ fn extract_publication_point_metrics(
|
||||
let result = json_str(object, &["result"])
|
||||
.unwrap_or("unknown")
|
||||
.to_string();
|
||||
*object_counts.entry((kind, result)).or_default() += 1;
|
||||
*object_counts.entry((kind.clone(), result)).or_default() += 1;
|
||||
*repo.object_counts.entry(kind).or_default() += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1531,6 +1533,21 @@ fn render_repo_metrics(writer: &mut PromWriter<'_>, instance: &str, repos: &[Rep
|
||||
*count as f64,
|
||||
);
|
||||
}
|
||||
for kind in ["manifest", "crl", "certificate", "roa", "aspa"] {
|
||||
let labels = [
|
||||
label("instance", instance),
|
||||
label("repo_id", &repo.repo_id),
|
||||
label("host", &repo.host),
|
||||
label("uri", &repo.uri),
|
||||
label("object_type", kind),
|
||||
];
|
||||
writer.gauge(
|
||||
"ours_rp_repository_objects_by_type",
|
||||
"Repository object count by object type from latest run report",
|
||||
&labels,
|
||||
repo.object_counts.get(kind).copied().unwrap_or(0) as f64,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2298,6 +2315,8 @@ mod tests {
|
||||
assert_eq!(snapshot.repo_stats.len(), 1);
|
||||
assert!(snapshot.repo_stats[0].sync_success);
|
||||
assert_eq!(snapshot.repo_stats[0].download_bytes, 333);
|
||||
assert_eq!(snapshot.repo_stats[0].object_counts["roa"], 2);
|
||||
assert_eq!(snapshot.repo_stats[0].object_counts["manifest"], 1);
|
||||
assert_eq!(snapshot.top_pp_by_object_count[0].object_count, 2);
|
||||
assert_eq!(snapshot.cir.as_ref().unwrap().objects, 2);
|
||||
assert_eq!(snapshot.ccr.as_ref().unwrap().state_items["tas"], 1);
|
||||
@@ -2305,6 +2324,10 @@ mod tests {
|
||||
assert!(metrics.contains("ours_rp_repository_info"));
|
||||
assert!(metrics.contains("ours_rp_repository_sync_success"));
|
||||
assert!(metrics.contains("ours_rp_repository_download_bytes"));
|
||||
assert!(metrics.contains("ours_rp_repository_objects_by_type"));
|
||||
assert!(metrics.contains(r#"ours_rp_repository_objects_by_type{instance="test",repo_id="#));
|
||||
assert!(metrics.contains(r#"object_type="roa"} 2"#));
|
||||
assert!(metrics.contains(r#"object_type="manifest"} 1"#));
|
||||
assert!(metrics.contains("ours_rp_large_publication_points"));
|
||||
assert!(metrics.contains("ours_rp_cir_objects"));
|
||||
assert!(metrics.contains("ours_rp_cir_objects_by_source"));
|
||||
|
||||
Reference in New Issue
Block a user