Commit 7f684958 authored by jingbo.wang's avatar jingbo.wang

top10 改成top n

parent e75fbe34
...@@ -20,6 +20,7 @@ const ( ...@@ -20,6 +20,7 @@ const (
var ( var (
cstZone = time.FixedZone("CST", 8*3600) cstZone = time.FixedZone("CST", 8*3600)
maxDuration = time.Millisecond * 600 maxDuration = time.Millisecond * 600
topN = 20
) )
//Human-readable number //Human-readable number
...@@ -96,10 +97,10 @@ func (s *Service) ReportForm() string { ...@@ -96,10 +97,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("4、常规cpu使用率:去针尖后的最高CPU使用率,针尖指的是CPU使用率暴增的场景\n") rtn.WriteString("4、常规cpu使用率:去针尖后的最高CPU使用率,针尖指的是CPU使用率暴增的场景\n")
rtn.WriteString("\n\n") rtn.WriteString("\n\n")
//服务接口中位响应时间TOP10 //服务接口中位响应时间TOP N
getMedianDurationPathList := s.GetMedianDurationPathList() getMedianDurationPathList := s.GetMedianDurationPathList()
if len(getMedianDurationPathList) != 0 { if len(getMedianDurationPathList) != 0 {
t = NewTable("服务接口中位响应时间TOP10", "排名", "响应时间", "接口", "访问量", "QPS") t = NewTable(fmt.Sprintf("服务接口中位响应时间TOP%d", topN), "排名", "响应时间", "接口", "访问量", "QPS")
for i, p := range getMedianDurationPathList { for i, p := range getMedianDurationPathList {
color := colorBlack color := colorBlack
if p.GetMedianDuration() > maxDuration { if p.GetMedianDuration() > maxDuration {
...@@ -114,7 +115,7 @@ func (s *Service) ReportForm() string { ...@@ -114,7 +115,7 @@ func (s *Service) ReportForm() string {
fmt.Sprintf("%.2f", p.GetQps()), fmt.Sprintf("%.2f", p.GetQps()),
) )
//取前10 //取前10
if i+1 == 10 { if i+1 == topN {
break break
} }
} }
...@@ -122,10 +123,10 @@ func (s *Service) ReportForm() string { ...@@ -122,10 +123,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("\n\n") rtn.WriteString("\n\n")
} }
//服务接口平均响应时间TOP10 //服务接口平均响应时间TOP N
getAverageDurationPathList := s.GetAverageDurationPathList() getAverageDurationPathList := s.GetAverageDurationPathList()
if len(getAverageDurationPathList) != 0 { if len(getAverageDurationPathList) != 0 {
t = NewTable("服务接口平均响应时间TOP10", "排名", "响应时间", "接口", "访问量", "QPS") t = NewTable(fmt.Sprintf("服务接口平均响应时间TOP%d", topN), "排名", "响应时间", "接口", "访问量", "QPS")
for i, p := range getAverageDurationPathList { for i, p := range getAverageDurationPathList {
color := colorBlack color := colorBlack
if p.GetAverageDuration() > maxDuration { if p.GetAverageDuration() > maxDuration {
...@@ -140,7 +141,7 @@ func (s *Service) ReportForm() string { ...@@ -140,7 +141,7 @@ func (s *Service) ReportForm() string {
fmt.Sprintf("%.2f", p.GetQps()), fmt.Sprintf("%.2f", p.GetQps()),
) )
//取前10 //取前10
if i+1 == 10 { if i+1 == topN {
break break
} }
} }
...@@ -148,10 +149,10 @@ func (s *Service) ReportForm() string { ...@@ -148,10 +149,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("\n\n") rtn.WriteString("\n\n")
} }
//服务接口峰值响应时间TOP10 //服务接口峰值响应时间TOP N
getMaxDurationPathList := s.GetMaxDurationPathList() getMaxDurationPathList := s.GetMaxDurationPathList()
if len(getMaxDurationPathList) != 0 { if len(getMaxDurationPathList) != 0 {
t = NewTable("服务接口峰值响应时间TOP10", "排名", "响应时间", "接口", "时间戳", "trace_id", "访问量") t = NewTable(fmt.Sprintf("服务接口峰值响应时间TOP%d", topN), "排名", "响应时间", "接口", "时间戳", "trace_id", "访问量")
for i, p := range getMaxDurationPathList { for i, p := range getMaxDurationPathList {
tp := p.GetMaxDurationTracePoint() tp := p.GetMaxDurationTracePoint()
color := colorBlack color := colorBlack
...@@ -167,8 +168,7 @@ func (s *Service) ReportForm() string { ...@@ -167,8 +168,7 @@ func (s *Service) ReportForm() string {
fmt.Sprintf(`<a href="http://zipkin-3c.xyqb.com/zipkin/traces/%s" target="_blank" rel="noopener noreferrer">%s</a>`, tp.TraceId, tp.TraceId), fmt.Sprintf(`<a href="http://zipkin-3c.xyqb.com/zipkin/traces/%s" target="_blank" rel="noopener noreferrer">%s</a>`, tp.TraceId, tp.TraceId),
hrn(p.GetCount()), hrn(p.GetCount()),
) )
//取前10 if i+1 == topN {
if i+1 == 10 {
break break
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment