-
Notifications
You must be signed in to change notification settings - Fork 672
/
metrics.go
59 lines (53 loc) · 1.51 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
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avalanche
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
type metrics struct {
numVtxRequests, numPendingVts, numMissingTxs prometheus.Gauge
getAncestorsVtxs prometheus.Histogram
}
// Initialize implements the Engine interface
func (m *metrics) Initialize(namespace string, registerer prometheus.Registerer) error {
m.numVtxRequests = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "vtx_requests",
Help: "Number of outstanding vertex requests",
})
m.numPendingVts = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "pending_vts",
Help: "Number of pending vertices",
})
m.numMissingTxs = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "missing_txs",
Help: "Number of missing transactions",
})
m.getAncestorsVtxs = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "get_ancestors_vtxs",
Help: "The number of vertices 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.numVtxRequests),
registerer.Register(m.numPendingVts),
registerer.Register(m.numMissingTxs),
registerer.Register(m.getAncestorsVtxs),
)
return errs.Err
}