Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
7f684958
Commit
7f684958
authored
Dec 12, 2019
by
jingbo.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
top10 改成top n
parent
e75fbe34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
report_form.go
pkg/report-form/report_form.go
+10
-10
No files found.
pkg/report-form/report_form.go
View file @
7f684958
...
...
@@ -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
"
)
//服务接口中位响应时间TOP
10
//服务接口中位响应时间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
"
)
}
//服务接口平均响应时间TOP
10
//服务接口平均响应时间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
"
)
}
//服务接口峰值响应时间TOP
10
//服务接口峰值响应时间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
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment