Commit 3a0e8d74 authored by vrg0's avatar vrg0

调整path记录策列,修复浅拷贝问题

parent f97a304a
...@@ -2,6 +2,7 @@ package points ...@@ -2,6 +2,7 @@ package points
import ( import (
"fmt" "fmt"
"strings"
"sync" "sync"
) )
...@@ -72,7 +73,11 @@ func NewStatistics() *Statistics { ...@@ -72,7 +73,11 @@ func NewStatistics() *Statistics {
} }
} }
func (s *Statistics) addServer(local localEndpoint, remote remoteEndpoint, tag tags) { func (s *Statistics) addServer(point TraceMsg) {
local := point.LocalEndpoint
//remote := point.RemoteEndpoint
tag := point.Tags
if _, ok := s.ServiceMap[local.ServiceName]; !ok { if _, ok := s.ServiceMap[local.ServiceName]; !ok {
s.ServiceMap[local.ServiceName] = NewServiceNode(local.ServiceName) s.ServiceMap[local.ServiceName] = NewServiceNode(local.ServiceName)
} }
...@@ -81,25 +86,33 @@ func (s *Statistics) addServer(local localEndpoint, remote remoteEndpoint, tag t ...@@ -81,25 +86,33 @@ func (s *Statistics) addServer(local localEndpoint, remote remoteEndpoint, tag t
s.ServiceMap[local.ServiceName].IpMap[local.Ipv4] = struct{}{} s.ServiceMap[local.ServiceName].IpMap[local.Ipv4] = struct{}{}
} }
path := tag.HttpMethod + "-" + tag.HttpPath path := strings.ToLower(point.Name)
if _, ok := methodMap[strings.ToLower(point.Name)]; ok {
path = strings.ToLower(tag.HttpMethod + "-" + tag.HttpPath)
}
_, ok := s.ServiceMap[local.ServiceName].PathMap[path] _, ok := s.ServiceMap[local.ServiceName].PathMap[path]
if !ok { if !ok {
s.ServiceMap[local.ServiceName].PathMap[path] = NewPathNode(path, local.ServiceName) s.ServiceMap[local.ServiceName].PathMap[path] = NewPathNode(path, local.ServiceName)
} }
} }
func (s *Statistics) addClient(local localEndpoint, remote remoteEndpoint, tag tags) { func (s *Statistics) addClient(point TraceMsg) {
for _, service := range s.ServiceMap { local := point.LocalEndpoint
for ip := range service.IpMap { remote := point.RemoteEndpoint
tag := point.Tags
for sName := range s.ServiceMap {
for ip := range s.ServiceMap[sName].IpMap {
if ip == remote.Ipv4 { if ip == remote.Ipv4 {
//添加服务 //添加服务
path := tag.HttpMethod + "-" + tag.HttpPath path := strings.ToLower(point.Name)
if _, ok := service.PathMap[path]; !ok { if _, ok := methodMap[strings.ToLower(point.Name)]; ok {
service.PathMap[path] = NewPathNode(path, service.ServiceName) path = strings.ToLower(tag.HttpMethod + "-" + tag.HttpPath)
}
if _, ok := s.ServiceMap[sName].PathMap[path]; !ok {
s.ServiceMap[sName].PathMap[path] = NewPathNode(path, s.ServiceMap[sName].ServiceName)
} }
//service.PathMap[path]. s.ServiceMap[sName].PathMap[path].RemoteServiceMap[local.ServiceName] = struct{}{}
service.PathMap[path].RemoteServiceMap[local.ServiceName] = struct{}{}
} }
} }
} }
...@@ -111,9 +124,9 @@ func (s *Statistics) AddNode(point TraceMsg) { ...@@ -111,9 +124,9 @@ func (s *Statistics) AddNode(point TraceMsg) {
switch point.Kind { switch point.Kind {
case "SERVER": case "SERVER":
s.addServer(point.LocalEndpoint, point.RemoteEndpoint, point.Tags) s.addServer(point)
case "CLIENT": case "CLIENT":
s.addClient(point.LocalEndpoint, point.RemoteEndpoint, point.Tags) s.addClient(point)
default: default:
//位置类型,不处理 //位置类型,不处理
} }
......
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