Commit 3a0e8d74 authored by vrg0's avatar vrg0

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

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