-
Notifications
You must be signed in to change notification settings - Fork 651
/
metrics.go
53 lines (47 loc) · 1.24 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
// (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/ava-labs/avalanchego/utils/wrappers"
)
type metrics struct {
numRequests, numBlocked prometheus.Gauge
getAncestorsBlks prometheus.Histogram
}
// Initialize the metrics
func (m *metrics) Initialize(namespace string, registerer prometheus.Registerer) error {
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.getAncestorsBlks = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "get_ancestors_blks",
Help: "The number of blocks fetched in a call to GetAncestors",
Buckets: []float64{
0,
1,
5,
10,
100,
500,
1000,
1500,
2000,
},
})
errs := wrappers.Errs{}
errs.Add(
registerer.Register(m.numRequests),
registerer.Register(m.numBlocked),
registerer.Register(m.getAncestorsBlks),
)
return errs.Err
}