Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e399e495
Unverified
Commit
e399e495
authored
Jun 05, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Use a continuously updated histogram rather than replacing it on each update.
parent
7de5042c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
57 deletions
+11
-57
histogram_snapshot.go
op-node/metrics/histogram_snapshot.go
+0
-44
metrics.go
op-node/metrics/metrics.go
+11
-13
No files found.
op-node/metrics/histogram_snapshot.go
deleted
100644 → 0
View file @
7de5042c
package
metrics
import
(
"sync/atomic"
"github.com/prometheus/client_golang/prometheus"
)
type
ReplaceableHistogramVec
struct
{
current
*
atomic
.
Value
opts
prometheus
.
HistogramOpts
variableLabels
[]
string
}
func
NewReplaceableHistogramVec
(
registry
*
prometheus
.
Registry
,
opts
prometheus
.
HistogramOpts
,
variableLabels
[]
string
)
*
ReplaceableHistogramVec
{
metric
:=
&
ReplaceableHistogramVec
{
current
:
&
atomic
.
Value
{},
opts
:
opts
,
variableLabels
:
variableLabels
,
}
metric
.
current
.
Store
(
prometheus
.
NewHistogramVec
(
opts
,
variableLabels
))
registry
.
MustRegister
(
metric
)
return
metric
}
func
(
c
*
ReplaceableHistogramVec
)
Replace
(
updater
func
(
h
*
prometheus
.
HistogramVec
))
{
h
:=
prometheus
.
NewHistogramVec
(
c
.
opts
,
c
.
variableLabels
)
updater
(
h
)
c
.
current
.
Store
(
h
)
}
func
(
c
*
ReplaceableHistogramVec
)
Describe
(
ch
chan
<-
*
prometheus
.
Desc
)
{
collector
,
ok
:=
c
.
current
.
Load
()
.
(
prometheus
.
Collector
)
if
ok
{
collector
.
Describe
(
ch
)
}
}
func
(
c
*
ReplaceableHistogramVec
)
Collect
(
ch
chan
<-
prometheus
.
Metric
)
{
collector
,
ok
:=
c
.
current
.
Load
()
.
(
prometheus
.
Collector
)
if
ok
{
collector
.
Collect
(
ch
)
}
}
op-node/metrics/metrics.go
View file @
e399e495
...
@@ -142,7 +142,7 @@ type Metrics struct {
...
@@ -142,7 +142,7 @@ type Metrics struct {
IPUnbans
prometheus
.
Counter
IPUnbans
prometheus
.
Counter
Dials
*
prometheus
.
CounterVec
Dials
*
prometheus
.
CounterVec
Accepts
*
prometheus
.
CounterVec
Accepts
*
prometheus
.
CounterVec
PeerScoresHistogram
*
Replaceable
HistogramVec
PeerScoresHistogram
*
prometheus
.
HistogramVec
ChannelInputBytes
prometheus
.
Counter
ChannelInputBytes
prometheus
.
Counter
...
@@ -324,7 +324,7 @@ func NewMetrics(procName string) *Metrics {
...
@@ -324,7 +324,7 @@ func NewMetrics(procName string) *Metrics {
},
[]
string
{
},
[]
string
{
"band"
,
"band"
,
}),
}),
PeerScoresHistogram
:
NewReplaceableHistogramVec
(
registry
,
prometheus
.
HistogramOpts
{
PeerScoresHistogram
:
factory
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"peer_scores_histogram"
,
Name
:
"peer_scores_histogram"
,
Help
:
"Histogram of currrently connected peer scores"
,
Help
:
"Histogram of currrently connected peer scores"
,
...
@@ -462,17 +462,15 @@ func NewMetrics(procName string) *Metrics {
...
@@ -462,17 +462,15 @@ func NewMetrics(procName string) *Metrics {
// SetPeerScores updates the peer score [prometheus.GaugeVec].
// SetPeerScores updates the peer score [prometheus.GaugeVec].
// This takes a map of labels to scores.
// This takes a map of labels to scores.
func
(
m
*
Metrics
)
SetPeerScores
(
scores
map
[
string
]
float64
,
allScores
[]
store
.
PeerScores
)
{
func
(
m
*
Metrics
)
SetPeerScores
(
scores
map
[
string
]
float64
,
allScores
[]
store
.
PeerScores
)
{
m
.
PeerScoresHistogram
.
Replace
(
func
(
h
*
prometheus
.
HistogramVec
)
{
for
_
,
scores
:=
range
allScores
{
for
_
,
scores
:=
range
allScores
{
m
.
PeerScoresHistogram
.
WithLabelValues
(
"total"
)
.
Observe
(
scores
.
Gossip
.
Total
)
h
.
WithLabelValues
(
"total"
)
.
Observe
(
scores
.
Gossip
.
Total
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"ipColocation"
)
.
Observe
(
scores
.
Gossip
.
IPColocationFactor
)
h
.
WithLabelValues
(
"ipColocation"
)
.
Observe
(
scores
.
Gossip
.
IPColocationFactor
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"behavioralPenalty"
)
.
Observe
(
scores
.
Gossip
.
BehavioralPenalty
)
h
.
WithLabelValues
(
"behavioralPenalty"
)
.
Observe
(
scores
.
Gossip
.
BehavioralPenalty
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"blocksFirstMessage"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
FirstMessageDeliveries
)
h
.
WithLabelValues
(
"blocksFirstMessage"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
FirstMessageDeliveries
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"blocksTimeInMesh"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
TimeInMesh
)
h
.
WithLabelValues
(
"blocksTimeInMesh"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
TimeInMesh
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"blocksMessageDeliveries"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
MeshMessageDeliveries
)
h
.
WithLabelValues
(
"blocksMessageDeliveries"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
MeshMessageDeliveries
)
m
.
PeerScoresHistogram
.
WithLabelValues
(
"blocksInvalidMessageDeliveries"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
InvalidMessageDeliveries
)
h
.
WithLabelValues
(
"blocksInvalidMessageDeliveries"
)
.
Observe
(
scores
.
Gossip
.
Blocks
.
InvalidMessageDeliveries
)
}
}
})
for
label
,
score
:=
range
scores
{
for
label
,
score
:=
range
scores
{
m
.
PeerScores
.
WithLabelValues
(
label
)
.
Set
(
score
)
m
.
PeerScores
.
WithLabelValues
(
label
)
.
Set
(
score
)
}
}
...
...
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