Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
3a0e8d74
Commit
3a0e8d74
authored
Feb 25, 2020
by
vrg0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整path记录策列,修复浅拷贝问题
parent
f97a304a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
path_statistics.go
pkg/points/path_statistics.go
+25
-12
No files found.
pkg/points/path_statistics.go
View file @
3a0e8d74
...
@@ -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
:
//位置类型,不处理
//位置类型,不处理
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment