-
Notifications
You must be signed in to change notification settings - Fork 32
/
metrics.go
75 lines (69 loc) · 2.41 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowman
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/flare-foundation/flare/utils/metric"
"github.com/flare-foundation/flare/utils/wrappers"
)
type metrics struct {
bootstrapFinished, numRequests, numBlocked, numBlockers, numNonVerifieds prometheus.Gauge
numBuilt, numBuildsFailed prometheus.Counter
getAncestorsBlks metric.Averager
}
// Initialize the metrics
func (m *metrics) Initialize(namespace string, reg prometheus.Registerer) error {
errs := wrappers.Errs{}
m.bootstrapFinished = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "bootstrap_finished",
Help: "Whether or not bootstrap process has completed. 1 is success, 0 is fail or ongoing.",
})
m.numRequests = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "requests",
Help: "Number of outstanding block requests",
})
m.numBlocked = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "blocked",
Help: "Number of blocks that are pending issuance",
})
m.numBlockers = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "blockers",
Help: "Number of blocks that are blocking other blocks from being issued because they haven't been issued",
})
m.numBuilt = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "blks_built",
Help: "Number of blocks that have been built locally",
})
m.numBuildsFailed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "blk_builds_failed",
Help: "Number of BuildBlock calls that have failed",
})
m.getAncestorsBlks = metric.NewAveragerWithErrs(
namespace,
"get_ancestors_blks",
"blocks fetched in a call to GetAncestors",
reg,
&errs,
)
m.numNonVerifieds = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "non_verified_blks",
Help: "Number of non-verified blocks in the memory",
})
errs.Add(
reg.Register(m.bootstrapFinished),
reg.Register(m.numRequests),
reg.Register(m.numBlocked),
reg.Register(m.numBlockers),
reg.Register(m.numBuilt),
reg.Register(m.numBuildsFailed),
reg.Register(m.numNonVerifieds),
)
return errs.Err
}