-
Notifications
You must be signed in to change notification settings - Fork 212
/
metrics.go
165 lines (151 loc) · 4.16 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
package tortoise
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spacemeshos/go-spacemesh/metrics"
)
const namespace = "tortoise"
var (
ballotsNumber = metrics.NewGauge(
"ballots",
namespace,
"Number of ballots in the state",
[]string{},
).WithLabelValues()
delayedBallots = metrics.NewGauge(
"delayed_ballots",
namespace,
"Number of ballots that are delayed due to the wrong beacon",
[]string{},
).WithLabelValues()
blocksNumber = metrics.NewGauge(
"blocks",
namespace,
"Number of blocks in the state",
[]string{},
).WithLabelValues()
layersNumber = metrics.NewGauge(
"layers",
namespace,
"Number of layers in the state",
[]string{},
).WithLabelValues()
epochsNumber = metrics.NewGauge(
"epochs",
namespace,
"Number of epochs in the state",
[]string{},
).WithLabelValues()
atxsNumber = metrics.NewGauge(
"atxs",
namespace,
"number of atxs in the tortoise state",
[]string{},
).WithLabelValues()
malfeasantNumber = metrics.NewGauge(
"malfeasant",
namespace,
"number of malfeasant identities",
[]string{},
).WithLabelValues()
)
var (
stateLayers = metrics.NewGauge(
"state_layers",
namespace,
"Layers in the state (evicted, verified, latest, processed)",
[]string{"kind"},
)
evictedLayer = stateLayers.WithLabelValues("evicted")
verifiedLayer = stateLayers.WithLabelValues("verified")
processedLayer = stateLayers.WithLabelValues("processed")
lastLayer = stateLayers.WithLabelValues("last")
)
var modeGauge = metrics.NewGauge(
"mode",
namespace,
"0 for verifying, 1 for full",
[]string{},
).WithLabelValues()
var errorsCounter = metrics.NewCounter(
"errors",
namespace,
"Counter for all errors",
[]string{},
).WithLabelValues()
var (
onBallotHist = metrics.NewHistogramWithBuckets(
"tortoise_on_ballot_ns",
namespace,
"Time to process ballot in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitBallotDuration = onBallotHist.WithLabelValues("wait")
decodeBallotDuration = onBallotHist.WithLabelValues("decode")
fcountBallotDuration = onBallotHist.WithLabelValues("full_count")
vcountBallotDuration = onBallotHist.WithLabelValues("verifying_count")
)
var (
onBlockHist = metrics.NewHistogramWithBuckets(
"tortoise_on_block_ns",
namespace,
"Time to process block in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitBlockDuration = onBlockHist.WithLabelValues("wait")
addBlockDuration = onBlockHist.WithLabelValues("add")
lateBlockDuration = onBlockHist.WithLabelValues("late")
)
var (
onHareOutputHist = metrics.NewHistogramWithBuckets(
"tortoise_on_hare_output_ns",
namespace,
"Time to process hare output in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitHareOutputDuration = onHareOutputHist.WithLabelValues("wait")
addHareOutput = onHareOutputHist.WithLabelValues("add")
)
var (
onAtxHist = metrics.NewHistogramWithBuckets(
"tortoise_on_atx_ns",
namespace,
"Time to add atx in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitAtxDuration = onAtxHist.WithLabelValues("wait")
addAtxDuration = onAtxHist.WithLabelValues("add")
)
var (
tallyVotesHist = metrics.NewHistogramWithBuckets(
"tortoise_tally_votes_ns",
namespace,
"Time for tally votes to complete in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitTallyVotes = tallyVotesHist.WithLabelValues("wait")
executeTallyVotes = tallyVotesHist.WithLabelValues("execute")
)
var (
encodeVotesHist = metrics.NewHistogramWithBuckets(
"tortoise_encode_votes_ns",
namespace,
"Time for encode votes to complete in ns.",
[]string{"step"},
prometheus.ExponentialBuckets(100_000, 2, 10),
)
waitEncodeVotes = encodeVotesHist.WithLabelValues("wait")
executeEncodeVotes = encodeVotesHist.WithLabelValues("execute")
)
// LayerDistanceToBaseBallot checks how far back a node needs to find a good ballot.
var layerDistanceToBaseBallot = metrics.NewHistogramWithBuckets(
"layer_distance_to_base_ballot",
namespace,
"How far back a node needs to find a good ballot",
[]string{},
prometheus.ExponentialBuckets(1, 2, 16),
).WithLabelValues()