-
Notifications
You must be signed in to change notification settings - Fork 672
/
metrics.go
166 lines (158 loc) · 6.06 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright (C) 2019-2024, 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/metric"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
const (
pullGossipSource = "pull_gossip"
pushGossipSource = "push_gossip"
builtSource = "built"
unknownSource = "unknown"
)
type metrics struct {
bootstrapFinished prometheus.Gauge
numRequests prometheus.Gauge
numBlocked prometheus.Gauge
numBlockers prometheus.Gauge
numNonVerifieds prometheus.Gauge
numBuilt prometheus.Counter
numBuildsFailed prometheus.Counter
numUselessPutBytes prometheus.Counter
numUselessPushQueryBytes prometheus.Counter
numMissingAcceptedBlocks prometheus.Counter
numProcessingAncestorFetchesFailed prometheus.Counter
numProcessingAncestorFetchesDropped prometheus.Counter
numProcessingAncestorFetchesSucceeded prometheus.Counter
numProcessingAncestorFetchesUnneeded prometheus.Counter
getAncestorsBlks metric.Averager
selectedVoteIndex metric.Averager
issuerStake metric.Averager
issued *prometheus.CounterVec
}
func newMetrics(namespace string, reg prometheus.Registerer) (*metrics, error) {
errs := wrappers.Errs{}
m := &metrics{
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.",
}),
numRequests: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "requests",
Help: "Number of outstanding block requests",
}),
numBlocked: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "blocked",
Help: "Number of blocks that are pending issuance",
}),
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",
}),
numNonVerifieds: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "non_verified_blks",
Help: "Number of non-verified blocks in the memory",
}),
numBuilt: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "blks_built",
Help: "Number of blocks that have been built locally",
}),
numBuildsFailed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "blk_builds_failed",
Help: "Number of BuildBlock calls that have failed",
}),
numUselessPutBytes: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_useless_put_bytes",
Help: "Amount of useless bytes received in Put messages",
}),
numUselessPushQueryBytes: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_useless_push_query_bytes",
Help: "Amount of useless bytes received in PushQuery messages",
}),
numMissingAcceptedBlocks: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_missing_accepted_blocks",
Help: "Number of times an accepted block height was referenced and it wasn't locally available",
}),
numProcessingAncestorFetchesFailed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_processing_ancestor_fetches_failed",
Help: "Number of votes that were dropped due to unknown blocks",
}),
numProcessingAncestorFetchesDropped: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_processing_ancestor_fetches_dropped",
Help: "Number of votes that were dropped due to decided blocks",
}),
numProcessingAncestorFetchesSucceeded: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_processing_ancestor_fetches_succeeded",
Help: "Number of votes that were applied to ancestor blocks",
}),
numProcessingAncestorFetchesUnneeded: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_processing_ancestor_fetches_unneeded",
Help: "Number of votes that were directly applied to blocks",
}),
getAncestorsBlks: metric.NewAveragerWithErrs(
namespace,
"get_ancestors_blks",
"blocks fetched in a call to GetAncestors",
reg,
&errs,
),
selectedVoteIndex: metric.NewAveragerWithErrs(
namespace,
"selected_vote_index",
"index of the voteID that was passed into consensus",
reg,
&errs,
),
issuerStake: metric.NewAveragerWithErrs(
namespace,
"issuer_stake",
"stake weight of the peer who provided a block that was issued into consensus",
reg,
&errs,
),
issued: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Name: "blks_issued",
Help: "number of blocks that have been issued into consensus by discovery mechanism",
}, []string{"source"}),
}
// Register the labels
m.issued.WithLabelValues(pullGossipSource)
m.issued.WithLabelValues(pushGossipSource)
m.issued.WithLabelValues(builtSource)
m.issued.WithLabelValues(unknownSource)
errs.Add(
reg.Register(m.bootstrapFinished),
reg.Register(m.numRequests),
reg.Register(m.numBlocked),
reg.Register(m.numBlockers),
reg.Register(m.numNonVerifieds),
reg.Register(m.numBuilt),
reg.Register(m.numBuildsFailed),
reg.Register(m.numUselessPutBytes),
reg.Register(m.numUselessPushQueryBytes),
reg.Register(m.numMissingAcceptedBlocks),
reg.Register(m.numProcessingAncestorFetchesFailed),
reg.Register(m.numProcessingAncestorFetchesDropped),
reg.Register(m.numProcessingAncestorFetchesSucceeded),
reg.Register(m.numProcessingAncestorFetchesUnneeded),
reg.Register(m.issued),
)
return m, errs.Err
}