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
b42bc5a0
Commit
b42bc5a0
authored
Feb 25, 2020
by
vrg0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整Client IP匹配策略
parent
3a0e8d74
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
36 deletions
+13
-36
path_statistics.go
pkg/points/path_statistics.go
+13
-36
No files found.
pkg/points/path_statistics.go
View file @
b42bc5a0
...
@@ -11,6 +11,7 @@ type PathNode struct {
...
@@ -11,6 +11,7 @@ type PathNode struct {
ServiceName
string
ServiceName
string
Path
string
Path
string
RemoteServiceMap
map
[
string
]
struct
{}
RemoteServiceMap
map
[
string
]
struct
{}
RemoteIpMap
map
[
string
]
struct
{}
}
}
func
NewPathNode
(
path
string
,
serviceName
string
)
PathNode
{
func
NewPathNode
(
path
string
,
serviceName
string
)
PathNode
{
...
@@ -18,6 +19,7 @@ func NewPathNode(path string, serviceName string) PathNode {
...
@@ -18,6 +19,7 @@ func NewPathNode(path string, serviceName string) PathNode {
Path
:
path
,
Path
:
path
,
ServiceName
:
serviceName
,
ServiceName
:
serviceName
,
RemoteServiceMap
:
make
(
map
[
string
]
struct
{}),
RemoteServiceMap
:
make
(
map
[
string
]
struct
{}),
RemoteIpMap
:
make
(
map
[
string
]
struct
{}),
}
}
}
}
...
@@ -75,7 +77,7 @@ func NewStatistics() *Statistics {
...
@@ -75,7 +77,7 @@ func NewStatistics() *Statistics {
func
(
s
*
Statistics
)
addServer
(
point
TraceMsg
)
{
func
(
s
*
Statistics
)
addServer
(
point
TraceMsg
)
{
local
:=
point
.
LocalEndpoint
local
:=
point
.
LocalEndpoint
//
remote := point.RemoteEndpoint
remote
:=
point
.
RemoteEndpoint
tag
:=
point
.
Tags
tag
:=
point
.
Tags
if
_
,
ok
:=
s
.
ServiceMap
[
local
.
ServiceName
];
!
ok
{
if
_
,
ok
:=
s
.
ServiceMap
[
local
.
ServiceName
];
!
ok
{
...
@@ -88,30 +90,27 @@ func (s *Statistics) addServer(point TraceMsg) {
...
@@ -88,30 +90,27 @@ func (s *Statistics) addServer(point TraceMsg) {
path
:=
strings
.
ToLower
(
point
.
Name
)
path
:=
strings
.
ToLower
(
point
.
Name
)
if
_
,
ok
:=
methodMap
[
strings
.
ToLower
(
point
.
Name
)];
ok
{
if
_
,
ok
:=
methodMap
[
strings
.
ToLower
(
point
.
Name
)];
ok
{
path
=
strings
.
ToLower
(
tag
.
HttpMethod
+
"
-
"
+
tag
.
HttpPath
)
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
)
}
}
s
.
ServiceMap
[
local
.
ServiceName
]
.
PathMap
[
path
]
.
RemoteIpMap
[
remote
.
Ipv4
]
=
struct
{}{}
}
}
func
(
s
*
Statistics
)
addClient
(
point
TraceMsg
)
{
func
(
s
*
Statistics
)
addClient
(
point
TraceMsg
)
{
local
:=
point
.
LocalEndpoint
local
:=
point
.
LocalEndpoint
remote
:=
point
.
RemoteEndpoint
tag
:=
point
.
Tags
tag
:=
point
.
Tags
for
sName
:=
range
s
.
ServiceMap
{
for
ip
:=
range
s
.
ServiceMap
[
sName
]
.
IpMap
{
if
ip
==
remote
.
Ipv4
{
//添加服务
path
:=
strings
.
ToLower
(
point
.
Name
)
path
:=
strings
.
ToLower
(
point
.
Name
)
if
_
,
ok
:=
methodMap
[
strings
.
ToLower
(
point
.
Name
)];
ok
{
if
_
,
ok
:=
methodMap
[
strings
.
ToLower
(
point
.
Name
)];
ok
{
path
=
strings
.
ToLower
(
tag
.
HttpMethod
+
"-"
+
tag
.
HttpPath
)
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
)
}
}
for
sName
:=
range
s
.
ServiceMap
{
if
_
,
ok
:=
s
.
ServiceMap
[
sName
]
.
PathMap
[
path
];
ok
{
if
_
,
ok
:=
s
.
ServiceMap
[
sName
]
.
PathMap
[
path
]
.
RemoteIpMap
[
local
.
Ipv4
];
ok
{
s
.
ServiceMap
[
sName
]
.
PathMap
[
path
]
.
RemoteServiceMap
[
local
.
ServiceName
]
=
struct
{}{}
s
.
ServiceMap
[
sName
]
.
PathMap
[
path
]
.
RemoteServiceMap
[
local
.
ServiceName
]
=
struct
{}{}
}
}
}
}
...
@@ -131,25 +130,3 @@ func (s *Statistics) AddNode(point TraceMsg) {
...
@@ -131,25 +130,3 @@ func (s *Statistics) AddNode(point TraceMsg) {
//位置类型,不处理
//位置类型,不处理
}
}
}
}
/*
type PathNode struct {
ServiceName string
Path string
SrcServiceList map[string]struct{}
SrcNodeIp map[string]struct{}
}
type Statistics struct {
PathMap map[string]PathNode
lock *sync.Mutex
}
func NewStatistics() *Statistics {
return &Statistics{
PathMap: make(map[string]PathNode),
lock: new(sync.Mutex),
}
}
*/
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