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

traceId版本问题导致的serice过多,临时方案

parent 9628d0ed
...@@ -103,7 +103,7 @@ func init() { ...@@ -103,7 +103,7 @@ func init() {
KafkaRecver = kafka.NewRecver(KafkaVersion, strings.Split(kafkaAddress, ","), kafkaLogger) KafkaRecver = kafka.NewRecver(KafkaVersion, strings.Split(kafkaAddress, ","), kafkaLogger)
InfluxDbAddress = Config.GetOrDefault(NamespaceApplication, "influxdb.address", "") InfluxDbAddress = Config.GetOrDefault(NamespaceApplication, "influxdb.address", "")
InfluxDbAddress = "http://172.20.6.33:8086" //InfluxDbAddress = "http://172.20.6.33:8086"
DaoFileCacheDir = Config.GetOrDefault(NamespaceApplication, "dao.file.cache.dir", "/var") DaoFileCacheDir = Config.GetOrDefault(NamespaceApplication, "dao.file.cache.dir", "/var")
//初始化registry //初始化registry
......
...@@ -39,6 +39,17 @@ type tags struct { ...@@ -39,6 +39,17 @@ type tags struct {
MvcControllerMethod string `json:"mvc.controller.method"` MvcControllerMethod string `json:"mvc.controller.method"`
} }
var (
methodMap = map[string]struct{}{
"options": {},
"get": {},
"post": {},
"put": {},
"delete": {},
"patch": {},
}
)
func TraceBaseInfoToPoint(data []byte) ([]*client.Point, error) { func TraceBaseInfoToPoint(data []byte) ([]*client.Point, error) {
rtn := make([]*client.Point, 0) rtn := make([]*client.Point, 0)
traceMsgList := make([]TraceMsg, 0) traceMsgList := make([]TraceMsg, 0)
...@@ -65,6 +76,11 @@ func buildTraceInfluxMsg(traceInfo TraceMsg) *client.Point { ...@@ -65,6 +76,11 @@ func buildTraceInfluxMsg(traceInfo TraceMsg) *client.Point {
return nil return nil
} }
//临时:屏蔽所有options请求
if strings.ToLower(traceInfo.Tags.HttpMethod) == "options" {
return nil
}
bytes, err := json.Marshal(traceInfo) bytes, err := json.Marshal(traceInfo)
if err != nil { if err != nil {
glog.Error("can not marshal traceInfo", traceInfo) glog.Error("can not marshal traceInfo", traceInfo)
...@@ -78,7 +94,11 @@ func buildTraceInfluxMsg(traceInfo TraceMsg) *client.Point { ...@@ -78,7 +94,11 @@ func buildTraceInfluxMsg(traceInfo TraceMsg) *client.Point {
tags := make(map[string]string) tags := make(map[string]string)
tags["sys_name"] = traceInfo.LocalEndpoint.ServiceName tags["sys_name"] = traceInfo.LocalEndpoint.ServiceName
tags["path"] = strings.ToLower(traceInfo.Tags.HttpMethod + " " + traceInfo.Name) if _, ok := methodMap[strings.ToLower(traceInfo.Tags.HttpMethod)]; ok {
tags["path"] = strings.ToLower(traceInfo.Tags.HttpMethod + " " + traceInfo.Tags.HttpPath)
} else {
tags["path"] = strings.ToLower(traceInfo.Name)
}
tags["host"] = traceInfo.LocalEndpoint.Ipv4 tags["host"] = traceInfo.LocalEndpoint.Ipv4
unix := time.Unix(0, traceInfo.Timestamp*1000) //精度为微秒,*1000后为纳秒 unix := time.Unix(0, traceInfo.Timestamp*1000) //精度为微秒,*1000后为纳秒
......
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