Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
0c1e54aa
Unverified
Commit
0c1e54aa
authored
4 years ago
by
Angelo Capossele
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix neighbor count in prometheus (#546)
parent
865ffd74
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/metrics/autopeering.go
+17
-13
17 additions, 13 deletions
plugins/metrics/autopeering.go
plugins/metrics/plugin.go
+1
-0
1 addition, 0 deletions
plugins/metrics/plugin.go
plugins/prometheus/autopeering.go
+1
-1
1 addition, 1 deletion
plugins/prometheus/autopeering.go
with
19 additions
and
14 deletions
plugins/metrics/autopeering.go
+
17
−
13
View file @
0c1e54aa
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
gossipPkg
"github.com/iotaledger/goshimmer/packages/gossip"
gossipPkg
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/hive.go/autopeering/selection"
"github.com/iotaledger/hive.go/autopeering/selection"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/events"
"go.uber.org/atomic"
)
)
var
(
var
(
...
@@ -14,11 +15,12 @@ var (
...
@@ -14,11 +15,12 @@ var (
neighborConnectionsLifeTime
time
.
Duration
neighborConnectionsLifeTime
time
.
Duration
neighborMutex
sync
.
RWMutex
neighborMutex
sync
.
RWMutex
connectionsCount
uint64
neighborConnectionsCount
atomic
.
Uint64
sumDistance
uint64
autopeeringConnectionsCount
uint64
minDistance
=
uint64
(
^
uint32
(
0
))
sumDistance
uint64
maxDistance
uint64
minDistance
=
uint64
(
^
uint32
(
0
))
distanceMutex
sync
.
RWMutex
maxDistance
uint64
distanceMutex
sync
.
RWMutex
)
)
var
(
var
(
...
@@ -29,10 +31,14 @@ var (
...
@@ -29,10 +31,14 @@ var (
neighborConnectionsLifeTime
+=
time
.
Since
(
n
.
ConnectionEstablished
())
neighborConnectionsLifeTime
+=
time
.
Since
(
n
.
ConnectionEstablished
())
})
})
onNeighborAdded
=
events
.
NewClosure
(
func
(
_
*
gossipPkg
.
Neighbor
)
{
neighborConnectionsCount
.
Inc
()
})
onAutopeeringSelection
=
events
.
NewClosure
(
func
(
ev
*
selection
.
PeeringEvent
)
{
onAutopeeringSelection
=
events
.
NewClosure
(
func
(
ev
*
selection
.
PeeringEvent
)
{
distanceMutex
.
Lock
()
distanceMutex
.
Lock
()
defer
distanceMutex
.
Unlock
()
defer
distanceMutex
.
Unlock
()
c
onnectionsCount
++
autopeeringC
onnectionsCount
++
distance
:=
uint64
(
ev
.
Distance
)
distance
:=
uint64
(
ev
.
Distance
)
if
distance
<
minDistance
{
if
distance
<
minDistance
{
minDistance
=
distance
minDistance
=
distance
...
@@ -61,11 +67,9 @@ func AvgNeighborConnectionLifeTime() float64 {
...
@@ -61,11 +67,9 @@ func AvgNeighborConnectionLifeTime() float64 {
return
float64
(
neighborConnectionsLifeTime
.
Milliseconds
())
/
float64
(
neighborDropCount
)
return
float64
(
neighborConnectionsLifeTime
.
Milliseconds
())
/
float64
(
neighborDropCount
)
}
}
// ConnectionsCount returns the neighbors connections count.
// NeighborConnectionsCount returns the neighbors connections count.
func
ConnectionsCount
()
uint64
{
func
NeighborConnectionsCount
()
uint64
{
distanceMutex
.
RLock
()
return
neighborConnectionsCount
.
Load
()
defer
distanceMutex
.
RUnlock
()
return
connectionsCount
}
}
// AutopeeringDistanceStats returns statistics of the autopeering distance function.
// AutopeeringDistanceStats returns statistics of the autopeering distance function.
...
@@ -73,10 +77,10 @@ func AutopeeringDistanceStats() (min, max uint64, avg float64) {
...
@@ -73,10 +77,10 @@ func AutopeeringDistanceStats() (min, max uint64, avg float64) {
distanceMutex
.
RLock
()
distanceMutex
.
RLock
()
defer
distanceMutex
.
RUnlock
()
defer
distanceMutex
.
RUnlock
()
min
,
max
=
minDistance
,
maxDistance
min
,
max
=
minDistance
,
maxDistance
if
c
onnectionsCount
==
0
{
if
autopeeringC
onnectionsCount
==
0
{
avg
=
0
avg
=
0
return
return
}
}
avg
=
float64
(
sumDistance
)
/
float64
(
c
onnectionsCount
)
avg
=
float64
(
sumDistance
)
/
float64
(
autopeeringC
onnectionsCount
)
return
return
}
}
This diff is collapsed.
Click to expand it.
plugins/metrics/plugin.go
+
1
−
0
View file @
0c1e54aa
...
@@ -130,6 +130,7 @@ func registerLocalMetrics() {
...
@@ -130,6 +130,7 @@ func registerLocalMetrics() {
}))
}))
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Attach
(
onNeighborRemoved
)
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Attach
(
onNeighborRemoved
)
gossip
.
Manager
()
.
Events
()
.
NeighborAdded
.
Attach
(
onNeighborAdded
)
autopeering
.
Selection
()
.
Events
()
.
IncomingPeering
.
Attach
(
onAutopeeringSelection
)
autopeering
.
Selection
()
.
Events
()
.
IncomingPeering
.
Attach
(
onAutopeeringSelection
)
autopeering
.
Selection
()
.
Events
()
.
OutgoingPeering
.
Attach
(
onAutopeeringSelection
)
autopeering
.
Selection
()
.
Events
()
.
OutgoingPeering
.
Attach
(
onAutopeeringSelection
)
...
...
This diff is collapsed.
Click to expand it.
plugins/prometheus/autopeering.go
+
1
−
1
View file @
0c1e54aa
...
@@ -58,7 +58,7 @@ func registerAutopeeringMetrics() {
...
@@ -58,7 +58,7 @@ func registerAutopeeringMetrics() {
func
collectAutopeeringMetrics
()
{
func
collectAutopeeringMetrics
()
{
neighborDropCount
.
Set
(
float64
(
metrics
.
NeighborDropCount
()))
neighborDropCount
.
Set
(
float64
(
metrics
.
NeighborDropCount
()))
avgNeighborConnectionLifeTime
.
Set
(
metrics
.
AvgNeighborConnectionLifeTime
())
avgNeighborConnectionLifeTime
.
Set
(
metrics
.
AvgNeighborConnectionLifeTime
())
connectionsCount
.
Set
(
float64
(
metrics
.
ConnectionsCount
()))
connectionsCount
.
Set
(
float64
(
metrics
.
Neighbor
ConnectionsCount
()))
min
,
max
,
avg
:=
metrics
.
AutopeeringDistanceStats
()
min
,
max
,
avg
:=
metrics
.
AutopeeringDistanceStats
()
minDistance
.
Set
(
float64
(
min
))
minDistance
.
Set
(
float64
(
min
))
maxDistance
.
Set
(
float64
(
max
))
maxDistance
.
Set
(
float64
(
max
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment