Commit 3cd60728 authored by xiaoguang.xu's avatar xiaoguang.xu

1. 修正server判定为continue

2. 增加性能检测net/http/pprof
3. 日志文件创建不擦除旧日志.
parent 10c844eb
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"git.quantgroup.cn/DevOps/enoch/service/job" "git.quantgroup.cn/DevOps/enoch/service/job"
"log" "log"
"net/http" "net/http"
_ "net/http/pprof"
"os" "os"
) )
...@@ -18,7 +19,7 @@ func main() { ...@@ -18,7 +19,7 @@ func main() {
flag.BoolVar(&quartz, "quartz", false, "quartz") flag.BoolVar(&quartz, "quartz", false, "quartz")
flag.Parse() flag.Parse()
file, err := os.Create("quantgroup.log") file, err := os.OpenFile("quantgroup.log", os.O_RDWR|os.O_CREATE, 0666)
defer func() { _ = file.Close() }() defer func() { _ = file.Close() }()
if err != nil { if err != nil {
log.Fatalln("create file error", err) log.Fatalln("create file error", err)
...@@ -39,6 +40,10 @@ func main() { ...@@ -39,6 +40,10 @@ func main() {
job.AutoEmailPerformInfo() job.AutoEmailPerformInfo()
} }
go func() {
http.ListenAndServe("0.0.0.0:8899", nil)
}()
http.HandleFunc("/duration", service.DurationInterface) http.HandleFunc("/duration", service.DurationInterface)
http.HandleFunc("/counter", service.CounterInterface) http.HandleFunc("/counter", service.CounterInterface)
......
...@@ -16,6 +16,7 @@ var httpMethod = map[string]string{ ...@@ -16,6 +16,7 @@ var httpMethod = map[string]string{
} }
func MsgProcess(msg string) { func MsgProcess(msg string) {
traceMsg := make([]TraceMsg, 3) //[]TraceMsg{} traceMsg := make([]TraceMsg, 3) //[]TraceMsg{}
err := json.Unmarshal([]byte(msg), &traceMsg) err := json.Unmarshal([]byte(msg), &traceMsg)
if err != nil { if err != nil {
...@@ -32,8 +33,9 @@ var pointSlice = make([]*client.Point, 0, batchSize) ...@@ -32,8 +33,9 @@ var pointSlice = make([]*client.Point, 0, batchSize)
func msgInfluxProcess(traceMsgs []TraceMsg) { func msgInfluxProcess(traceMsgs []TraceMsg) {
for _, traceMsg := range traceMsgs { for _, traceMsg := range traceMsgs {
if traceMsg.Kind != "SERVER" { if traceMsg.Kind != "SERVER" {
break continue
} }
path := traceMsg.Name path := traceMsg.Name
...@@ -52,12 +54,11 @@ func msgInfluxProcess(traceMsgs []TraceMsg) { ...@@ -52,12 +54,11 @@ func msgInfluxProcess(traceMsgs []TraceMsg) {
fields["msg"] = msg fields["msg"] = msg
tags := make(map[string]string, ) tags := make(map[string]string)
tags["sys_name"] = sysName tags["sys_name"] = sysName
tags["path"] = path tags["path"] = path
tags["host"] = traceMsg.LocalEndpoint.Ipv4 tags["host"] = traceMsg.LocalEndpoint.Ipv4
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
...@@ -93,11 +94,10 @@ func batchWrite(pointArray []*client.Point) { ...@@ -93,11 +94,10 @@ func batchWrite(pointArray []*client.Point) {
points.AddPoints(pointArray) points.AddPoints(pointArray)
err = c.Write(points) err = c.Write(points)
fmt.Println("写入数据",len(pointArray)) fmt.Println("写入数据", len(pointArray))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }
func msgRedisProcess(traceMsg []TraceMsg) { func msgRedisProcess(traceMsg []TraceMsg) {
......
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