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

top10 改成top n

parent e75fbe34
......@@ -20,6 +20,7 @@ const (
var (
cstZone = time.FixedZone("CST", 8*3600)
maxDuration = time.Millisecond * 600
topN = 20
)
//Human-readable number
......@@ -96,10 +97,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("4、常规cpu使用率:去针尖后的最高CPU使用率,针尖指的是CPU使用率暴增的场景\n")
rtn.WriteString("\n\n")
//服务接口中位响应时间TOP10
//服务接口中位响应时间TOP N
getMedianDurationPathList := s.GetMedianDurationPathList()
if len(getMedianDurationPathList) != 0 {
t = NewTable("服务接口中位响应时间TOP10", "排名", "响应时间", "接口", "访问量", "QPS")
t = NewTable(fmt.Sprintf("服务接口中位响应时间TOP%d", topN), "排名", "响应时间", "接口", "访问量", "QPS")
for i, p := range getMedianDurationPathList {
color := colorBlack
if p.GetMedianDuration() > maxDuration {
......@@ -114,7 +115,7 @@ func (s *Service) ReportForm() string {
fmt.Sprintf("%.2f", p.GetQps()),
)
//取前10
if i+1 == 10 {
if i+1 == topN {
break
}
}
......@@ -122,10 +123,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("\n\n")
}
//服务接口平均响应时间TOP10
//服务接口平均响应时间TOP N
getAverageDurationPathList := s.GetAverageDurationPathList()
if len(getAverageDurationPathList) != 0 {
t = NewTable("服务接口平均响应时间TOP10", "排名", "响应时间", "接口", "访问量", "QPS")
t = NewTable(fmt.Sprintf("服务接口平均响应时间TOP%d", topN), "排名", "响应时间", "接口", "访问量", "QPS")
for i, p := range getAverageDurationPathList {
color := colorBlack
if p.GetAverageDuration() > maxDuration {
......@@ -140,7 +141,7 @@ func (s *Service) ReportForm() string {
fmt.Sprintf("%.2f", p.GetQps()),
)
//取前10
if i+1 == 10 {
if i+1 == topN {
break
}
}
......@@ -148,10 +149,10 @@ func (s *Service) ReportForm() string {
rtn.WriteString("\n\n")
}
//服务接口峰值响应时间TOP10
//服务接口峰值响应时间TOP N
getMaxDurationPathList := s.GetMaxDurationPathList()
if len(getMaxDurationPathList) != 0 {
t = NewTable("服务接口峰值响应时间TOP10", "排名", "响应时间", "接口", "时间戳", "trace_id", "访问量")
t = NewTable(fmt.Sprintf("服务接口峰值响应时间TOP%d", topN), "排名", "响应时间", "接口", "时间戳", "trace_id", "访问量")
for i, p := range getMaxDurationPathList {
tp := p.GetMaxDurationTracePoint()
color := colorBlack
......@@ -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),
hrn(p.GetCount()),
)
//取前10
if i+1 == 10 {
if i+1 == topN {
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