状态码统计数组越界

This commit is contained in:
wood chen 2024-12-05 08:27:19 +08:00
parent 864ebcc610
commit ba691431f4

View File

@ -292,9 +292,10 @@ func (c *Collector) GetStats() map[string]interface{} {
// 状态码统计
statusStats := make(map[string]int64)
statusGroups := []string{"1xx", "2xx", "3xx", "4xx", "5xx"}
for i := range c.statusStats {
statusStats[statusGroups[i]] = c.statusStats[i].Load()
if i < len(c.statusStats) {
statusStats[fmt.Sprintf("%dxx", i+1)] = c.statusStats[i].Load()
}
}
stats["status_code_stats"] = statusStats