-
Notifications
You must be signed in to change notification settings - Fork 670
/
metrics.go
64 lines (57 loc) · 1.89 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
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package bootstrap
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
type metrics struct {
numFetchedVts, numDroppedVts, numAcceptedVts,
numFetchedTxs, numDroppedTxs, numAcceptedTxs prometheus.Counter
}
// Initialize implements the Engine interface
func (m *metrics) Initialize(
namespace string,
registerer prometheus.Registerer,
) error {
m.numFetchedVts = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "fetched_vts",
Help: "Number of vertices fetched during bootstrapping",
})
m.numDroppedVts = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "dropped_vts",
Help: "Number of vertices dropped during bootstrapping",
})
m.numAcceptedVts = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted_vts",
Help: "Number of vertices accepted during bootstrapping",
})
m.numFetchedTxs = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "fetched_txs",
Help: "Number of transactions fetched during bootstrapping",
})
m.numDroppedTxs = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "dropped_txs",
Help: "Number of transactions dropped during bootstrapping",
})
m.numAcceptedTxs = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted_txs",
Help: "Number of transactions accepted during bootstrapping",
})
errs := wrappers.Errs{}
errs.Add(
registerer.Register(m.numFetchedVts),
registerer.Register(m.numDroppedVts),
registerer.Register(m.numAcceptedVts),
registerer.Register(m.numFetchedTxs),
registerer.Register(m.numDroppedTxs),
registerer.Register(m.numAcceptedTxs),
)
return errs.Err
}