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
f7a265d6
Commit
f7a265d6
authored
Dec 10, 2019
by
jingbo.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加qps数据
parent
3cb116c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
3 deletions
+42
-3
email.go
pkg/email/email.go
+1
-1
path.go
pkg/report-form/path.go
+15
-0
service.go
pkg/report-form/service.go
+17
-2
service_map.go
pkg/report-form/service_map.go
+9
-0
No files found.
pkg/email/email.go
View file @
f7a265d6
...
@@ -18,7 +18,7 @@ func SendEmail(title string, content string, receiver ...string) {
...
@@ -18,7 +18,7 @@ func SendEmail(title string, content string, receiver ...string) {
//m.SetHeader("To", []string{receiver})
//m.SetHeader("To", []string{receiver})
m
.
SetHeader
(
"To"
,
receiver
...
)
m
.
SetHeader
(
"To"
,
receiver
...
)
m
.
SetHeader
(
"Subject"
,
title
)
m
.
SetHeader
(
"Subject"
,
title
)
m
.
SetBody
(
"text/html"
,
"<
pre>"
+
content
+
"</pre
>"
)
m
.
SetBody
(
"text/html"
,
"<
div><pre>"
+
content
+
"</pre></div
>"
)
userName
:=
"program@quantgroup.cn"
userName
:=
"program@quantgroup.cn"
pwd
:=
"Fuck147999!!!"
pwd
:=
"Fuck147999!!!"
...
...
pkg/report-form/path.go
View file @
f7a265d6
...
@@ -24,6 +24,7 @@ type Path struct {
...
@@ -24,6 +24,7 @@ type Path struct {
averageDuration
time
.
Duration
//平均响应时间
averageDuration
time
.
Duration
//平均响应时间
sumDuration
time
.
Duration
//总响应时间
sumDuration
time
.
Duration
//总响应时间
medianDuration
time
.
Duration
//中位响应时间
medianDuration
time
.
Duration
//中位响应时间
qps
int
//每秒的访问量
variance
float64
//标准差
variance
float64
//标准差
maxDurationTracePoint
TracePoint
//最大响应时间的TracePoint
maxDurationTracePoint
TracePoint
//最大响应时间的TracePoint
}
}
...
@@ -43,9 +44,18 @@ func NewPath(serviceName string, path string, startTime time.Time, endTime time.
...
@@ -43,9 +44,18 @@ func NewPath(serviceName string, path string, startTime time.Time, endTime time.
rtn
.
initAverageDuration
()
rtn
.
initAverageDuration
()
rtn
.
initMedianDuration
()
rtn
.
initMedianDuration
()
rtn
.
initMaxDurationTracePoint
()
rtn
.
initMaxDurationTracePoint
()
rtn
.
initQps
()
return
rtn
,
true
return
rtn
,
true
}
}
//初始化qps
func
(
p
*
Path
)
initQps
()
{
if
p
.
startTime
.
Unix
()
>=
p
.
endTime
.
Unix
()
{
return
}
p
.
qps
=
p
.
count
/
int
(
p
.
endTime
.
Sub
(
p
.
startTime
)
.
Seconds
())
}
//初始化访问次数
//初始化访问次数
func
(
p
*
Path
)
initCount
()
{
func
(
p
*
Path
)
initCount
()
{
const
sqlGetCount
=
`SELECT count("traceId") AS count FROM trace_info `
+
const
sqlGetCount
=
`SELECT count("traceId") AS count FROM trace_info `
+
...
@@ -188,6 +198,11 @@ func (p *Path) GetSumDuration() time.Duration {
...
@@ -188,6 +198,11 @@ func (p *Path) GetSumDuration() time.Duration {
return
p
.
sumDuration
return
p
.
sumDuration
}
}
//获取qps
func
(
p
*
Path
)
GetQps
()
int
{
return
p
.
qps
}
//获取平均响应时间
//获取平均响应时间
func
(
p
*
Path
)
GetAverageDuration
()
time
.
Duration
{
func
(
p
*
Path
)
GetAverageDuration
()
time
.
Duration
{
return
p
.
averageDuration
return
p
.
averageDuration
...
...
pkg/report-form/service.go
View file @
f7a265d6
...
@@ -24,6 +24,7 @@ type Service struct {
...
@@ -24,6 +24,7 @@ type Service struct {
maxMedianPath
*
Path
//最大中位响应时间path
maxMedianPath
*
Path
//最大中位响应时间path
maxAveragePath
*
Path
//最大平均响应时间path
maxAveragePath
*
Path
//最大平均响应时间path
maxDurationTracePoint
*
TracePoint
//最大响应时间的tracePoint
maxDurationTracePoint
*
TracePoint
//最大响应时间的tracePoint
qps
int
//node相关
//node相关
nodeMap
map
[
string
]
*
Node
//节点列表
nodeMap
map
[
string
]
*
Node
//节点列表
}
}
...
@@ -46,6 +47,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
...
@@ -46,6 +47,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
endTime
:
endTime
,
endTime
:
endTime
,
pathMap
:
make
(
map
[
string
]
*
Path
),
pathMap
:
make
(
map
[
string
]
*
Path
),
nodeMap
:
make
(
map
[
string
]
*
Node
),
nodeMap
:
make
(
map
[
string
]
*
Node
),
qps
:
0
,
}
}
//初始化path
//初始化path
...
@@ -69,6 +71,8 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
...
@@ -69,6 +71,8 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
//初始化访问时间相关的参数
//初始化访问时间相关的参数
rtn
.
initDuration
()
rtn
.
initDuration
()
//初始化qps
rtn
.
initQps
()
//初始化node
//初始化node
nodeList
:=
rtn
.
getNodeList
()
nodeList
:=
rtn
.
getNodeList
()
...
@@ -80,6 +84,13 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
...
@@ -80,6 +84,13 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
return
&
rtn
return
&
rtn
}
}
//初始化qps
func
(
s
*
Service
)
initQps
()
{
for
_
,
p
:=
range
s
.
pathMap
{
s
.
qps
+=
p
.
GetQps
()
}
}
//获取服务名称
//获取服务名称
func
(
s
*
Service
)
Name
()
string
{
func
(
s
*
Service
)
Name
()
string
{
return
s
.
name
return
s
.
name
...
@@ -213,6 +224,11 @@ func (s *Service) GetAverageDurationPathList() []*Path {
...
@@ -213,6 +224,11 @@ func (s *Service) GetAverageDurationPathList() []*Path {
return
rtn
return
rtn
}
}
//获取qps
func
(
s
*
Service
)
GetQps
()
int
{
return
s
.
qps
}
//获取 MedianDuration Path 排行
//获取 MedianDuration Path 排行
func
(
s
*
Service
)
GetMedianDurationPathList
()
[]
*
Path
{
func
(
s
*
Service
)
GetMedianDurationPathList
()
[]
*
Path
{
rtn
:=
make
([]
*
Path
,
0
)
rtn
:=
make
([]
*
Path
,
0
)
...
@@ -231,7 +247,6 @@ func (s *Service) GetMedianDurationPathList() []*Path {
...
@@ -231,7 +247,6 @@ func (s *Service) GetMedianDurationPathList() []*Path {
return
rtn
return
rtn
}
}
//获取 MaxDuration Path 排行
//获取 MaxDuration Path 排行
func
(
s
*
Service
)
GetMaxDurationPathList
()
[]
*
Path
{
func
(
s
*
Service
)
GetMaxDurationPathList
()
[]
*
Path
{
rtn
:=
make
([]
*
Path
,
0
)
rtn
:=
make
([]
*
Path
,
0
)
...
...
pkg/report-form/service_map.go
View file @
f7a265d6
...
@@ -143,6 +143,15 @@ func (sm *ServiceMap) GetMaxDiskServiceList() []*Service {
...
@@ -143,6 +143,15 @@ func (sm *ServiceMap) GetMaxDiskServiceList() []*Service {
return
rtn
return
rtn
}
}
//获取qps
func
(
sm
*
ServiceMap
)
GetQps
()
int
{
rtn
:=
0
for
_
,
s
:=
range
sm
.
serviceMap
{
rtn
+=
s
.
GetQps
()
}
return
rtn
}
//服务平均响应时间排行
//服务平均响应时间排行
func
(
sm
*
ServiceMap
)
GetAverageDurationServiceList
()
[]
*
Service
{
func
(
sm
*
ServiceMap
)
GetAverageDurationServiceList
()
[]
*
Service
{
rtn
:=
make
([]
*
Service
,
0
)
rtn
:=
make
([]
*
Service
,
0
)
...
...
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