mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 16:41:54 +08:00
refactor(metrics): Enhance path metrics sorting with secondary lexicographic ordering
- Update path metrics sorting to consider request count and path name - Implement secondary sorting by path name when request counts are equal - Improve deterministic ordering of metrics for consistent display
This commit is contained in:
parent
ed63121a00
commit
76b549aa90
@ -254,9 +254,14 @@ func (c *Collector) GetStats() map[string]interface{} {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
// 按请求数降序排序
|
// 按请求数降序排序,请求数相同时按路径字典序排序
|
||||||
sort.Slice(pathMetrics, func(i, j int) bool {
|
sort.Slice(pathMetrics, func(i, j int) bool {
|
||||||
return pathMetrics[i].GetRequestCount() > pathMetrics[j].GetRequestCount()
|
countI := pathMetrics[i].GetRequestCount()
|
||||||
|
countJ := pathMetrics[j].GetRequestCount()
|
||||||
|
if countI != countJ {
|
||||||
|
return countI > countJ
|
||||||
|
}
|
||||||
|
return pathMetrics[i].Path < pathMetrics[j].Path
|
||||||
})
|
})
|
||||||
|
|
||||||
// 只保留前10个
|
// 只保留前10个
|
||||||
|
Loading…
x
Reference in New Issue
Block a user