Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ale
autoradio
Commits
67d18932
Commit
67d18932
authored
Apr 14, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some instrumentation to the statusManager
parent
e353e685
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
node/instrumentation.go
node/instrumentation.go
+14
-0
node/status.go
node/status.go
+20
-0
No files found.
node/instrumentation.go
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"
,
...
...
node/status.go
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
)
{
...
...
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