Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ale
autoradio
Commits
67d18932
Commit
67d18932
authored
5 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add some instrumentation to the statusManager
parent
e353e685
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
v2.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
node/instrumentation.go
+14
-0
14 additions, 0 deletions
node/instrumentation.go
node/status.go
+20
-0
20 additions, 0 deletions
node/status.go
with
34 additions
and
0 deletions
node/instrumentation.go
+
14
−
0
View file @
67d18932
...
...
@@ -52,6 +52,20 @@ var (
},
)
// Status protocol (gossip) metrics.
gossipNumNodes
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"gossip_peer_count"
,
Help
:
"Number of peers seen by the gossip protocol."
,
},
)
gossipOldestTS
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"gossip_oldest_ts"
,
Help
:
"Timestamp of the oldest update from any active peer."
,
},
)
// Descriptors for the nodeCollector below.
numListenersDesc
=
prometheus
.
NewDesc
(
"status_num_listeners"
,
...
...
This diff is collapsed.
Click to expand it.
node/status.go
+
20
−
0
View file @
67d18932
...
...
@@ -149,6 +149,24 @@ func (m *statusManager) mergeRemoteStatuses(remote []*pb.Status) {
m
.
statuses
=
s
}
// Export the number of known nodes, and the timestamp of the oldest
// update seen, to monitoring, so we can have a rough idea of when the
// gossip protocol isn't working.
func
(
m
*
statusManager
)
updateMetrics
()
{
m
.
mx
.
Lock
()
var
oldest
uint64
for
_
,
s
:=
range
m
.
statuses
{
t
:=
s
.
Timestamp
if
oldest
==
0
||
t
<
oldest
{
oldest
=
t
}
}
gossipNumNodes
.
Set
(
float64
(
len
(
m
.
statuses
)))
gossipOldestTS
.
Set
(
float64
(
oldest
))
m
.
mx
.
Unlock
()
}
func
(
m
*
statusManager
)
tick
(
ctx
context
.
Context
)
{
pctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
gossipTimeout
)
defer
cancel
()
...
...
@@ -157,6 +175,8 @@ func (m *statusManager) tick(ctx context.Context) {
if
err
!=
nil
&&
err
!=
context
.
Canceled
{
log
.
Printf
(
"status: gossip error: %v"
,
err
)
}
m
.
updateMetrics
()
}
func
(
m
*
statusManager
)
Exchange
(
ctx
context
.
Context
,
req
*
pb
.
ExchangeRequest
)
(
*
pb
.
ExchangeResponse
,
error
)
{
...
...
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