Commit f7a265d6 authored by jingbo.wang's avatar jingbo.wang

添加qps数据

parent 3cb116c8
......@@ -18,7 +18,7 @@ func SendEmail(title string, content string, receiver ...string) {
//m.SetHeader("To", []string{receiver})
m.SetHeader("To", receiver...)
m.SetHeader("Subject", title)
m.SetBody("text/html", "<pre>"+content+"</pre>")
m.SetBody("text/html", "<div><pre>"+content+"</pre></div>")
userName := "program@quantgroup.cn"
pwd := "Fuck147999!!!"
......
......@@ -24,6 +24,7 @@ type Path struct {
averageDuration time.Duration //平均响应时间
sumDuration time.Duration //总响应时间
medianDuration time.Duration //中位响应时间
qps int //每秒的访问量
variance float64 //标准差
maxDurationTracePoint TracePoint //最大响应时间的TracePoint
}
......@@ -43,9 +44,18 @@ func NewPath(serviceName string, path string, startTime time.Time, endTime time.
rtn.initAverageDuration()
rtn.initMedianDuration()
rtn.initMaxDurationTracePoint()
rtn.initQps()
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() {
const sqlGetCount = `SELECT count("traceId") AS count FROM trace_info ` +
......@@ -188,6 +198,11 @@ func (p *Path) GetSumDuration() time.Duration {
return p.sumDuration
}
//获取qps
func (p *Path) GetQps() int {
return p.qps
}
//获取平均响应时间
func (p *Path) GetAverageDuration() time.Duration {
return p.averageDuration
......
......@@ -24,6 +24,7 @@ type Service struct {
maxMedianPath *Path //最大中位响应时间path
maxAveragePath *Path //最大平均响应时间path
maxDurationTracePoint *TracePoint //最大响应时间的tracePoint
qps int
//node相关
nodeMap map[string]*Node //节点列表
}
......@@ -46,6 +47,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
endTime: endTime,
pathMap: make(map[string]*Path),
nodeMap: make(map[string]*Node),
qps: 0,
}
//初始化path
......@@ -59,7 +61,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
if _, ok := IgnorePathMap[strings.ToLower(pathSplit[1])]; ok {
continue
}
glog.Info("init path: ", rtn.name, " ", path)
glog.Info("init path: ", rtn.name, " ", path)
pathObj, ok := NewPath(rtn.name, path, rtn.startTime, rtn.endTime)
if !ok {
continue
......@@ -69,6 +71,8 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
//初始化访问时间相关的参数
rtn.initDuration()
//初始化qps
rtn.initQps()
//初始化node
nodeList := rtn.getNodeList()
......@@ -80,6 +84,13 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
return &rtn
}
//初始化qps
func (s *Service) initQps() {
for _, p := range s.pathMap {
s.qps += p.GetQps()
}
}
//获取服务名称
func (s *Service) Name() string {
return s.name
......@@ -213,6 +224,11 @@ func (s *Service) GetAverageDurationPathList() []*Path {
return rtn
}
//获取qps
func (s *Service) GetQps() int {
return s.qps
}
//获取 MedianDuration Path 排行
func (s *Service) GetMedianDurationPathList() []*Path {
rtn := make([]*Path, 0)
......@@ -231,7 +247,6 @@ func (s *Service) GetMedianDurationPathList() []*Path {
return rtn
}
//获取 MaxDuration Path 排行
func (s *Service) GetMaxDurationPathList() []*Path {
rtn := make([]*Path, 0)
......
......@@ -143,6 +143,15 @@ func (sm *ServiceMap) GetMaxDiskServiceList() []*Service {
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 {
rtn := make([]*Service, 0)
......
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