-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation.go
355 lines (321 loc) · 13.4 KB
/
instrumentation.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
package state
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
// Example
//stateRandomCounter = prometheus.NewCounter(prometheus.CounterOpts{
// Name: "dcnt_state_randomcounter_total",
// Help: "Just a basic counter that can only go up",
//})
//
// Entry Syncing Controller
ESMissingQueue = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_missing_entry_queue",
Help: "Number of known missing entries in our queue to find.",
})
ESMissing = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_missing_entries",
Help: "Number of known missing entries",
})
ESFound = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_found_entries",
Help: "Number of known missing entries found.",
})
ESAsking = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_asking_missing_entries",
Help: "Number we are asking for of the known missing entries.",
})
ESHighestAsking = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_highest_asking_entries",
Help: "Highest entry DBHeight which has has a request made.",
})
ESHighestMissing = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_highest_missing_entries",
Help: "Highest DBHeight of the entries we know are missing.",
})
ESFirstMissing = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_first_missing_entries",
Help: "First DBHeight with a missing entry",
})
ESDBHTComplete = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_entry_dbheight_complete",
Help: "First DBHeight with a missing entry",
})
ESAvgRequests = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_es_average_requests",
Help: "Average number of times we have had to request a missing entry",
})
HighestAck = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_highest_ack",
Help: "Acknowledgement with the highest directory block height",
})
HighestKnown = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_highest_known",
Help: "Highest known block (which can be different than the highest ack)",
})
HighestSaved = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_highest_saved",
Help: "Highest saved block to the database",
})
HighestCompleted = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_highest_completed",
Help: "Highest completed block, which may or may not be saved to the database",
})
// TPS
TotalTransactionPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_txrate_total_tps",
Help: "Total transactions over life of node",
})
InstantTransactionPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_txrate_instant_tps",
Help: "Total transactions over life of node weighted for last 3 seconds",
})
// Torrent
stateTorrentSyncingLower = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_torrentsync_lower_gauge",
Help: "The lower limit of torrent sync",
})
stateTorrentSyncingUpper = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_torrentsync_upper_gauge",
Help: "The upper limit of torrent sync",
})
// Queues
CurrentMessageQueueInMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "dcnt_state_queue_current_general_inmsg_vec",
Help: "Instrumenting the current inmsg queue ",
}, []string{"message"})
TotalMessageQueueInMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "dcnt_state_queue_total_general_inmsg_vec",
Help: "Instrumenting the inmsg queue ",
}, []string{"message"})
CurrentMessageQueueApiGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "dcnt_state_queue_current_general_api_vec",
Help: "Instrumenting the current API queue ",
}, []string{"message"})
TotalMessageQueueApiGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "dcnt_state_queue_total_general_api_vec",
Help: "Instrumenting the API queue ",
}, []string{"message"})
TotalMessageQueueNetOutMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "dcnt_state_queue_total_general_netoutmsg_vec",
Help: "Instrumenting the netoutmsg queue ",
}, []string{"message"})
// MsgQueue chan
TotalMsgQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_msgqueue_total_inputs",
Help: "Tally of total messages gone into MsgQueue (useful for rating)",
})
TotalMsgQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_msgqueue_total_outputs",
Help: "Tally of total messages drained out of MsgQueue (useful for rating)",
})
// Holding Queue
TotalHoldingQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_total_inputs",
Help: "Tally of total messages gone into Holding (useful for rating)",
})
TotalHoldingQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_total_outputs",
Help: "Tally of total messages drained out of Holding (useful for rating)",
})
TotalHoldingQueueRecycles = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_total_recycles",
Help: "Tally of total messages recycled thru Holding (useful for rating)",
})
HoldingQueueDBSigInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_dbsig_inputs",
Help: "Tally of DBSig messages gone into Holding (useful for rating)",
})
HoldingQueueDBSigOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_dbsig_outputs",
Help: "Tally of DBSig messages drained out of Holding",
})
HoldingQueueCommitEntryInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_commitentry_inputs",
Help: "Tally of CommitEntry messages gone into Holding (useful for rating)",
})
HoldingQueueCommitEntryOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_commitentry_outputs",
Help: "Tally of CommitEntry messages drained out of Holding",
})
HoldingQueueCommitChainInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_commitchain_inputs",
Help: "Tally of CommitChain messages gone into Holding (useful for rating)",
})
HoldingQueueCommitChainOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_commitchain_outputs",
Help: "Tally of CommitChain messages drained out of Holding",
})
HoldingQueueRevealEntryInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_revealentry_inputs",
Help: "Tally of RevealEntry messages gone into Holding (useful for rating)",
})
HoldingQueueRevealEntryOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_holding_queue_revealentry_outputs",
Help: "Tally of RevealEntry messages drained out of Holding",
})
// Acks Queue
TotalAcksInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_acks_total_inputs",
Help: "Tally of total messages gone into Acks (useful for rating)",
})
TotalAcksOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_acks_total_outputs",
Help: "Tally of total messages drained out of Acks (useful for rating)",
})
// Commits map
TotalCommitsInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_commits_total_inputs",
Help: "Tally of total messages gone into Commits (useful for rating)",
})
TotalCommitsOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_commits_total_outputs",
Help: "Tally of total messages drained out of Commits (useful for rating)",
})
// XReview Queue
TotalXReviewQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_xreview_queue_total_inputs",
Help: "Tally of total messages gone into XReview (useful for rating)",
})
TotalXReviewQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_xreview_queue_total_outputs",
Help: "Tally of total messages drained out of XReview (useful for rating)",
})
// Executions
LeaderExecutions = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_leader_executions",
Help: "Tally of total messages executed via LeaderExecute",
})
FollowerExecutions = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_follower_executions",
Help: "Tally of total messages executed via FollowerExecute",
})
LeaderEOMExecutions = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_leader_eom_executions",
Help: "Tally of total messages executed via LeaderExecuteEOM",
})
FollowerEOMExecutions = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_follower_eom_executions",
Help: "Tally of total messages executed via FollowerExecuteEOM",
})
FollowerMissingMsgExecutions = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_follower_mm_executions",
Help: "Tally of total messages executed via FollowerExecuteMissingMsg",
})
// ProcessList
TotalProcessListInputs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_process_list_inputs",
Help: "Tally of total messages gone into ProcessLists (useful for rating)",
})
TotalProcessListProcesses = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_process_list_processes",
Help: "Tally of total messages processed from ProcessLists (useful for rating)",
})
TotalProcessEOMs = prometheus.NewCounter(prometheus.CounterOpts{
Name: "dcnt_state_process_eom_processes",
Help: "Tally of EOM messages processed from ProcessLists (useful for rating)",
})
// Durations
TotalReviewHoldingTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_review_holding_time",
Help: "Time spent in ReviewHolding()",
})
TotalProcessXReviewTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_process_xreview_time",
Help: "Time spent Processing XReview",
})
TotalProcessProcChanTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_process_proc_chan_time",
Help: "Time spent Processing Process Chan",
})
TotalEmptyLoopTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_empty_loop_time",
Help: "Time spent in empty loop",
})
TotalAckLoopTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_ack_loop_time",
Help: "Time spent in ack loop",
})
TotalExecuteMsgTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "dcnt_state_execute_msg_time",
Help: "Time spent in executeMsg",
})
)
var registered bool = false
// RegisterPrometheus registers the variables to be exposed. This can only be run once, hence the
// boolean flag to prevent panics if launched more than once. This is called in NetStart
func RegisterPrometheus() {
if registered {
return
}
registered = true
// Example Cont.
// prometheus.MustRegister(stateRandomCounter)
// Entry syncing
prometheus.MustRegister(ESAsking)
prometheus.MustRegister(ESHighestAsking)
prometheus.MustRegister(ESFirstMissing)
prometheus.MustRegister(ESMissing)
prometheus.MustRegister(ESFound)
prometheus.MustRegister(ESDBHTComplete)
prometheus.MustRegister(ESMissingQueue)
prometheus.MustRegister(ESHighestMissing)
prometheus.MustRegister(ESAvgRequests)
prometheus.MustRegister(HighestAck)
prometheus.MustRegister(HighestKnown)
prometheus.MustRegister(HighestSaved)
prometheus.MustRegister(HighestCompleted)
// TPS
prometheus.MustRegister(TotalTransactionPerSecond)
prometheus.MustRegister(InstantTransactionPerSecond)
// Torrent
prometheus.MustRegister(stateTorrentSyncingLower)
prometheus.MustRegister(stateTorrentSyncingUpper)
// Queues
prometheus.MustRegister(CurrentMessageQueueInMsgGeneralVec)
prometheus.MustRegister(TotalMessageQueueInMsgGeneralVec)
prometheus.MustRegister(CurrentMessageQueueApiGeneralVec)
prometheus.MustRegister(TotalMessageQueueApiGeneralVec)
prometheus.MustRegister(TotalMessageQueueNetOutMsgGeneralVec)
// MsgQueue chan
prometheus.MustRegister(TotalMsgQueueInputs)
prometheus.MustRegister(TotalMsgQueueOutputs)
// Holding
prometheus.MustRegister(TotalHoldingQueueInputs)
prometheus.MustRegister(TotalHoldingQueueOutputs)
prometheus.MustRegister(HoldingQueueDBSigInputs)
prometheus.MustRegister(HoldingQueueDBSigOutputs)
prometheus.MustRegister(HoldingQueueCommitEntryInputs)
prometheus.MustRegister(HoldingQueueCommitEntryOutputs)
prometheus.MustRegister(HoldingQueueCommitChainInputs)
prometheus.MustRegister(HoldingQueueCommitChainOutputs)
prometheus.MustRegister(HoldingQueueRevealEntryInputs)
prometheus.MustRegister(HoldingQueueRevealEntryOutputs)
// Acks
prometheus.MustRegister(TotalAcksInputs)
prometheus.MustRegister(TotalAcksOutputs)
// Execution
prometheus.MustRegister(LeaderExecutions)
prometheus.MustRegister(FollowerExecutions)
prometheus.MustRegister(LeaderEOMExecutions)
prometheus.MustRegister(FollowerEOMExecutions)
prometheus.MustRegister(FollowerMissingMsgExecutions)
// ProcessList
prometheus.MustRegister(TotalProcessListInputs)
prometheus.MustRegister(TotalProcessListProcesses)
prometheus.MustRegister(TotalProcessEOMs)
// XReview Queue
prometheus.MustRegister(TotalXReviewQueueInputs)
prometheus.MustRegister(TotalXReviewQueueOutputs)
// Commits map
prometheus.MustRegister(TotalCommitsInputs)
prometheus.MustRegister(TotalCommitsOutputs)
// Durations
prometheus.MustRegister(TotalReviewHoldingTime)
prometheus.MustRegister(TotalProcessXReviewTime)
prometheus.MustRegister(TotalProcessProcChanTime)
prometheus.MustRegister(TotalEmptyLoopTime)
prometheus.MustRegister(TotalAckLoopTime)
prometheus.MustRegister(TotalExecuteMsgTime)
}