Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
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
iota-imt
goshimmer
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 (
gossipPkg
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/hive.go/autopeering/selection"
"github.com/iotaledger/hive.go/events"
"go.uber.org/atomic"
)
var
(
...
...
@@ -14,11 +15,12 @@ var (
neighborConnectionsLifeTime
time
.
Duration
neighborMutex
sync
.
RWMutex
connectionsCount
uint64
sumDistance
uint64
minDistance
=
uint64
(
^
uint32
(
0
))
maxDistance
uint64
distanceMutex
sync
.
RWMutex
neighborConnectionsCount
atomic
.
Uint64
autopeeringConnectionsCount
uint64
sumDistance
uint64
minDistance
=
uint64
(
^
uint32
(
0
))
maxDistance
uint64
distanceMutex
sync
.
RWMutex
)
var
(
...
...
@@ -29,10 +31,14 @@ var (
neighborConnectionsLifeTime
+=
time
.
Since
(
n
.
ConnectionEstablished
())
})
onNeighborAdded
=
events
.
NewClosure
(
func
(
_
*
gossipPkg
.
Neighbor
)
{
neighborConnectionsCount
.
Inc
()
})
onAutopeeringSelection
=
events
.
NewClosure
(
func
(
ev
*
selection
.
PeeringEvent
)
{
distanceMutex
.
Lock
()
defer
distanceMutex
.
Unlock
()
c
onnectionsCount
++
autopeeringC
onnectionsCount
++
distance
:=
uint64
(
ev
.
Distance
)
if
distance
<
minDistance
{
minDistance
=
distance
...
...
@@ -61,11 +67,9 @@ func AvgNeighborConnectionLifeTime() float64 {
return
float64
(
neighborConnectionsLifeTime
.
Milliseconds
())
/
float64
(
neighborDropCount
)
}
// ConnectionsCount returns the neighbors connections count.
func
ConnectionsCount
()
uint64
{
distanceMutex
.
RLock
()
defer
distanceMutex
.
RUnlock
()
return
connectionsCount
// NeighborConnectionsCount returns the neighbors connections count.
func
NeighborConnectionsCount
()
uint64
{
return
neighborConnectionsCount
.
Load
()
}
// AutopeeringDistanceStats returns statistics of the autopeering distance function.
...
...
@@ -73,10 +77,10 @@ func AutopeeringDistanceStats() (min, max uint64, avg float64) {
distanceMutex
.
RLock
()
defer
distanceMutex
.
RUnlock
()
min
,
max
=
minDistance
,
maxDistance
if
c
onnectionsCount
==
0
{
if
autopeeringC
onnectionsCount
==
0
{
avg
=
0
return
}
avg
=
float64
(
sumDistance
)
/
float64
(
c
onnectionsCount
)
avg
=
float64
(
sumDistance
)
/
float64
(
autopeeringC
onnectionsCount
)
return
}
This diff is collapsed.
Click to expand it.
plugins/metrics/plugin.go
+
1
−
0
View file @
0c1e54aa
...
...
@@ -130,6 +130,7 @@ func registerLocalMetrics() {
}))
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Attach
(
onNeighborRemoved
)
gossip
.
Manager
()
.
Events
()
.
NeighborAdded
.
Attach
(
onNeighborAdded
)
autopeering
.
Selection
()
.
Events
()
.
IncomingPeering
.
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() {
func
collectAutopeeringMetrics
()
{
neighborDropCount
.
Set
(
float64
(
metrics
.
NeighborDropCount
()))
avgNeighborConnectionLifeTime
.
Set
(
metrics
.
AvgNeighborConnectionLifeTime
())
connectionsCount
.
Set
(
float64
(
metrics
.
ConnectionsCount
()))
connectionsCount
.
Set
(
float64
(
metrics
.
Neighbor
ConnectionsCount
()))
min
,
max
,
avg
:=
metrics
.
AutopeeringDistanceStats
()
minDistance
.
Set
(
float64
(
min
))
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