Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Dec 4, 2023
1 parent 0d45cb1 commit 94abec4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/metrics/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ pub fn sort_metrics_txt(metrics: &str) -> String {
let (first_line, metrics_content) = metrics.split_at(first_line_idx);

let mut entries = metrics_content
.split("\n\n")
.map(|s| s.trim().to_string())
.split("\n\n") //splitting by double new line to get separate metrics
.map(|s| {
let trimmed = s.trim();
let mut lines = trimmed.split('\n').collect::<Vec<_>>();
lines.sort(); //sort by properties
lines.join("\n")
})
.collect::<Vec<String>>();
entries.sort();
entries.sort(); //sort by metric name

first_line.to_string() + "\n" + entries.join("\n\n").as_str()
}
Expand Down

0 comments on commit 94abec4

Please sign in to comment.