-
Notifications
You must be signed in to change notification settings - Fork 146
/
chain.go
746 lines (674 loc) · 27.1 KB
/
chain.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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
package metrics
import (
"sync"
"sync/atomic"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/samber/lo"
iotago "github.com/iotaledger/iota.go/v3"
"github.com/iotaledger/iota.go/v3/nodeclient"
"github.com/iotaledger/wasp/packages/isc"
)
const (
labelNameChain = "chain"
labelNamePipeName = "pipe_name"
labelNameMessageType = "message_type"
labelNameInMilestone = "in_milestone"
labelNameInStateOutputMetrics = "in_state_output"
labelNameInAliasOutputMetrics = "in_alias_output"
labelNameInOutputMetrics = "in_output"
labelNameInOnLedgerRequestMetrics = "in_on_ledger_request"
labelNameInTxInclusionStateMetrics = "in_tx_inclusion_state"
labelNameOutPublishStateTransactionMetrics = "out_publish_state_transaction"
labelNameOutPublishGovernanceTransactionMetrics = "out_publish_gov_transaction"
labelNameOutPullLatestOutputMetrics = "out_pull_latest_output"
labelNameOutPullTxInclusionStateMetrics = "out_pull_tx_inclusion_state"
labelNameOutPullOutputByIDMetrics = "out_pull_output_by_id"
labelTxPublishResult = "result"
labelNameWebapiRequestOperation = "api_req_type"
labelNameWebapiRequestStatusCode = "api_req_status_code"
labelNameWebapiEvmRPCSuccess = "success"
)
type IChainMetrics interface {
IChainPipeMetrics
IChainBlockWALMetrics
IChainConsensusMetrics
IChainMempoolMetrics
IChainMessageMetrics
IChainStateMetrics
IChainStateManagerMetrics
IChainNodeConnMetrics
IWebAPIMetrics
}
var (
_ IChainMetrics = &emptyChainMetrics{}
_ IChainMetrics = &chainMetrics{}
)
type messageMetric[T any] struct {
provider *ChainMetricsProvider
metricsLabels prometheus.Labels
messagesCount atomic.Uint32
lastMessage T
lastMessageTime time.Time
}
func newMessageMetric[T any](provider *ChainMetricsProvider, msgType string) *messageMetric[T] {
metricsLabels := prometheus.Labels{
labelNameMessageType: msgType,
}
// init values so they appear in prometheus
provider.messagesL1.With(metricsLabels)
provider.lastL1MessageTime.With(metricsLabels)
return &messageMetric[T]{
provider: provider,
metricsLabels: metricsLabels,
}
}
func (m *messageMetric[T]) IncMessages(msg T, ts ...time.Time) {
timestamp := time.Now()
if len(ts) > 0 {
timestamp = ts[0]
}
m.messagesCount.Add(1)
m.lastMessage = msg
m.lastMessageTime = timestamp
m.provider.messagesL1.With(m.metricsLabels).Inc()
m.provider.lastL1MessageTime.With(m.metricsLabels).Set(float64(timestamp.Unix()))
}
func (m *messageMetric[T]) MessagesTotal() uint32 {
return m.messagesCount.Load()
}
func (m *messageMetric[T]) LastMessageTime() time.Time {
return m.lastMessageTime
}
func (m *messageMetric[T]) LastMessage() T {
return m.lastMessage
}
type emptyChainMetrics struct {
IChainPipeMetrics
IChainBlockWALMetrics
IChainConsensusMetrics
IChainMempoolMetrics
IChainMessageMetrics
IChainStateMetrics
IChainStateManagerMetrics
IChainNodeConnMetrics
IWebAPIMetrics
}
func NewEmptyChainMetrics() IChainMetrics {
return &emptyChainMetrics{
IChainPipeMetrics: NewEmptyChainPipeMetrics(),
IChainBlockWALMetrics: NewEmptyChainBlockWALMetrics(),
IChainConsensusMetrics: NewEmptyChainConsensusMetric(),
IChainMempoolMetrics: NewEmptyChainMempoolMetric(),
IChainMessageMetrics: NewEmptyChainMessageMetrics(),
IChainStateMetrics: NewEmptyChainStateMetric(),
IChainStateManagerMetrics: NewEmptyChainStateManagerMetric(),
IChainNodeConnMetrics: NewEmptyChainNodeConnMetric(),
IWebAPIMetrics: NewEmptyWebAPIMetrics(),
}
}
type chainMetrics struct {
*chainPipeMetrics
*chainBlockWALMetrics
*chainConsensusMetric
*chainMempoolMetric
*chainMessageMetrics
*chainStateMetric
*chainStateManagerMetric
*chainNodeConnMetric
*webAPIChainMetrics
}
func newChainMetrics(provider *ChainMetricsProvider, chainID isc.ChainID) *chainMetrics {
return &chainMetrics{
chainPipeMetrics: newChainPipeMetric(provider, chainID),
chainBlockWALMetrics: newChainBlockWALMetrics(provider, chainID),
chainConsensusMetric: newChainConsensusMetric(provider, chainID),
chainMempoolMetric: newChainMempoolMetric(provider, chainID),
chainMessageMetrics: newChainMessageMetrics(provider, chainID),
chainStateMetric: newChainStateMetric(provider, chainID),
chainStateManagerMetric: newChainStateManagerMetric(provider, chainID),
chainNodeConnMetric: newChainNodeConnMetric(provider, chainID),
webAPIChainMetrics: newWebAPIChainMetrics(provider, chainID),
}
}
// ChainMetricsProvider holds all metrics for all chains per chain
type ChainMetricsProvider struct {
chainsLock *sync.RWMutex
chainsRegistered map[isc.ChainID]*chainMetrics
// We use Func variant of a metric here, thus we register them
// explicitly when they are created. Therefore we need a registry here.
pipeLenRegistry *prometheus.Registry
// blockWAL
blockWALFailedWrites *prometheus.CounterVec
blockWALFailedReads *prometheus.CounterVec
blockWALBlocksAdded *prometheus.CounterVec
blockWALMaxBlockIndex *prometheus.CounterVec
// consensus
consensusVMRunTime *prometheus.HistogramVec
consensusVMRunTimePerReq *prometheus.HistogramVec
consensusVMRunReqCount *prometheus.HistogramVec
// mempool
blocksTotalPerChain *prometheus.CounterVec // TODO: Outdated and should be removed?
requestsReceivedOffLedger *prometheus.CounterVec // TODO: Outdated and should be removed?
requestsReceivedOnLedger *prometheus.CounterVec // TODO: Outdated and should be removed?
requestsProcessed *prometheus.CounterVec // TODO: Outdated and should be removed?
requestsAckMessages *prometheus.CounterVec // TODO: Outdated and should be removed?
requestsProcessingTime *prometheus.GaugeVec // TODO: Outdated and should be removed?
mempoolTimePoolSize *prometheus.GaugeVec
mempoolOnLedgerPoolSize *prometheus.GaugeVec
mempoolOnLedgerReqTime *prometheus.HistogramVec
mempoolOffLedgerPoolSize *prometheus.GaugeVec
mempoolOffLedgerReqTime *prometheus.HistogramVec
mempoolTotalSize *prometheus.GaugeVec
mempoolMissingReqs *prometheus.GaugeVec
// messages
messagesL1 *prometheus.CounterVec
lastL1MessageTime *prometheus.GaugeVec
messagesL1Chain *prometheus.CounterVec
lastL1MessageTimeChain *prometheus.GaugeVec
inMilestoneMetrics *messageMetric[*nodeclient.MilestoneInfo]
inStateOutputMetrics *messageMetric[*InStateOutput]
inAliasOutputMetrics *messageMetric[*iotago.AliasOutput]
inOutputMetrics *messageMetric[*InOutput]
inOnLedgerRequestMetrics *messageMetric[isc.OnLedgerRequest]
inTxInclusionStateMetrics *messageMetric[*TxInclusionStateMsg]
outPublishStateTransactionMetrics *messageMetric[*StateTransaction]
outPublishGovernanceTransactionMetrics *messageMetric[*iotago.Transaction]
outPullLatestOutputMetrics *messageMetric[interface{}]
outPullTxInclusionStateMetrics *messageMetric[iotago.TransactionID]
outPullOutputByIDMetrics *messageMetric[iotago.OutputID]
// chain state / tips
chainActiveStateWant *prometheus.GaugeVec
chainActiveStateHave *prometheus.GaugeVec
chainConfirmedStateWant *prometheus.GaugeVec
chainConfirmedStateHave *prometheus.GaugeVec
// state manager
smCacheSize *prometheus.GaugeVec
smBlocksFetching *prometheus.GaugeVec
smBlocksPending *prometheus.GaugeVec
smBlocksCommitted *prometheus.CounterVec
smRequestsWaiting *prometheus.GaugeVec
smCSPHandlingDuration *prometheus.HistogramVec
smCDSHandlingDuration *prometheus.HistogramVec
smCBPHandlingDuration *prometheus.HistogramVec
smFSDHandlingDuration *prometheus.HistogramVec
smTTHandlingDuration *prometheus.HistogramVec
smBlockFetchDuration *prometheus.HistogramVec
// node conn
ncL1RequestReceived *prometheus.CounterVec
ncL1AliasOutputReceived *prometheus.CounterVec
ncTXPublishStarted *prometheus.CounterVec
ncTXPublishResult *prometheus.HistogramVec
// webapi
webAPIRequests *prometheus.HistogramVec
webAPIEvmRPCCalls *prometheus.HistogramVec
}
//nolint:funlen
func NewChainMetricsProvider() *ChainMetricsProvider {
postTimeBuckets := prometheus.ExponentialBucketsRange(0.1, 60*60, 17) // Time to confirm/reject a TX in L1 [0.1s - 1h].
execTimeBuckets := prometheus.ExponentialBucketsRange(0.01, 100, 17) // Execution of misc functions.
recCountBuckets := prometheus.ExponentialBucketsRange(1, 1000, 16)
m := &ChainMetricsProvider{
chainsLock: &sync.RWMutex{},
chainsRegistered: map[isc.ChainID]*chainMetrics{},
//
// blockWAL
//
blockWALFailedWrites: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "wal",
Name: "failed_writes_total",
Help: "Total number of writes to WAL that failed",
}, []string{labelNameChain}),
blockWALFailedReads: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "wal",
Name: "failed_reads_total",
Help: "Total number of reads failed while replaying WAL",
}, []string{labelNameChain}),
blockWALBlocksAdded: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "wal",
Name: "blocks_added",
Help: "Total number of blocks added into WAL",
}, []string{labelNameChain}),
blockWALMaxBlockIndex: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "wal",
Name: "max_block_index",
Help: "Largest index of block added into WAL",
}, []string{labelNameChain}),
//
// consensus
//
consensusVMRunTime: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "consensus",
Name: "vm_run_time",
Help: "Time (s) it takes to run the VM per chain block.",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
consensusVMRunTimePerReq: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "consensus",
Name: "vm_run_time_per_req",
Help: "Time (s) it takes to run the VM per request.",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
consensusVMRunReqCount: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "consensus",
Name: "vm_run_req_count",
Help: "Number of requests processed per VM run.",
Buckets: recCountBuckets,
}, []string{labelNameChain}),
//
// mempool
//
blocksTotalPerChain: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "blocks",
Name: "total",
Help: "Number of blocks per chain",
}, []string{labelNameChain}),
requestsReceivedOffLedger: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "requests",
Name: "off_ledger_total",
Help: "Number of off-ledger requests made to chain",
}, []string{labelNameChain}),
requestsReceivedOnLedger: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "requests",
Name: "on_ledger_total",
Help: "Number of on-ledger requests made to the chain",
}, []string{labelNameChain}),
requestsProcessed: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "requests",
Name: "processed_total",
Help: "Number of requests processed per chain",
}, []string{labelNameChain}),
requestsAckMessages: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "requests",
Name: "received_acks_total",
Help: "Number of received request acknowledgements per chain",
}, []string{labelNameChain}),
requestsProcessingTime: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "requests",
Name: "processing_time",
Help: "Time to process requests per chain",
}, []string{labelNameChain}),
mempoolTimePoolSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "time_pool_size",
Help: "Number of postponed requests in mempool.",
}, []string{labelNameChain}),
mempoolOnLedgerPoolSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "on_ledger_pool_size",
Help: "Number of On Ledger requests in mempool.",
}, []string{labelNameChain}),
mempoolOnLedgerReqTime: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "on_ledger_req_time",
Help: "Time (s) an on-ledger request stayed in the mempool before removing it.",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
mempoolOffLedgerPoolSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "off_ledger_pool_size",
Help: "Number of Off Ledger requests in mempool.",
}, []string{labelNameChain}),
mempoolOffLedgerReqTime: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "off_ledger_req_time",
Help: "Time (s) an off-ledger request stayed in the mempool before removing it.",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
mempoolTotalSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "total_pool_size",
Help: "Total requests in mempool.",
}, []string{labelNameChain}),
mempoolMissingReqs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "mempool",
Name: "missing_reqs",
Help: "Number of requests missing at this node (asking others to send them).",
}, []string{labelNameChain}),
//
// messages // TODO: Review, if they are used/needed.
//
messagesL1: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "messages",
Name: "messages_total",
Help: "Number of messages sent/received by L1 connection",
}, []string{labelNameMessageType}),
lastL1MessageTime: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "messages",
Name: "last_message_time",
Help: "Last time when a message was sent/received by L1 connection",
}, []string{labelNameMessageType}),
messagesL1Chain: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "messages",
Name: "chain_messages_total",
Help: "Number of messages sent/received by L1 connection of the chain",
}, []string{labelNameChain, labelNameMessageType}),
lastL1MessageTimeChain: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "messages",
Name: "chain_last_message_time",
Help: "Last time when a message was sent/received by L1 connection of the chain",
}, []string{labelNameChain, labelNameMessageType}),
//
// chain state / tips.
//
chainActiveStateWant: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "chain",
Name: "active_state_want",
Help: "We try to get blocks till this StateIndex for the active state.",
}, []string{labelNameChain}),
chainActiveStateHave: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "chain",
Name: "active_state_have",
Help: "We received blocks till this StateIndex for the active state.",
}, []string{labelNameChain}),
chainConfirmedStateWant: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "chain",
Name: "confirmed_state_want",
Help: "We try to get blocks till this StateIndex for the confirmed state.",
}, []string{labelNameChain}),
chainConfirmedStateHave: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "chain",
Name: "confirmed_state_have",
Help: "We received blocks till this StateIndex for the confirmed state.",
}, []string{labelNameChain}),
//
// state manager
//
smCacheSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "cache_size",
Help: "Number of blocks stored in cache",
}, []string{labelNameChain}),
smBlocksFetching: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "blocks_fetching",
Help: "Number of blocks the node is waiting from other nodes",
}, []string{labelNameChain}),
smBlocksPending: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "blocks_pending",
Help: "Number of blocks the node has fetched but hasn't committed, because the node doesn't have their ancestors",
}, []string{labelNameChain}),
smBlocksCommitted: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "blocks_committed",
Help: "Number of blocks the node has committed to the store",
}, []string{labelNameChain}),
smRequestsWaiting: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "requests_waiting",
Help: "Number of requests from other components of the node waiting for response from the state manager. Note that StateDiff request is counted as two requests as it has to obtain two possibly different blocks.",
}, []string{labelNameChain}),
smCSPHandlingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "consensus_state_proposal_duration",
Help: "The duration (s) from starting handling ConsensusStateProposal request till responding to the consensus",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
smCDSHandlingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "consensus_decided_state_duration",
Help: "The duration (s) from starting handling ConsensusDecidedState request till responding to the consensus",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
smCBPHandlingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "consensus_block_produced_duration",
Help: "The duration (s) from starting till finishing handling ConsensusBlockProduced, which includes responding to the consensus",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
smFSDHandlingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "chain_fetch_state_diff_duration",
Help: "The duration (s) from starting handling ChainFetchStateDiff request till responding to the chain",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
smTTHandlingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "timer_tick_duration",
Help: "The duration (s) from starting till finishing handling StateManagerTimerTick request",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
smBlockFetchDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "state_manager",
Name: "block_fetch_duration",
Help: "The duration (s) from starting fetching block from other till it is received in this node",
Buckets: execTimeBuckets,
}, []string{labelNameChain}),
//
// node conn
//
ncL1RequestReceived: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "node_conn",
Name: "l1_request_received",
Help: "A number of confirmed requests received from L1.",
}, []string{labelNameChain}),
ncL1AliasOutputReceived: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "node_conn",
Name: "l1_alias_output_received",
Help: "A number of confirmed alias outputs received from L1.",
}, []string{labelNameChain}),
ncTXPublishStarted: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "iota_wasp",
Subsystem: "node_conn",
Name: "tx_publish_started",
Help: "A number of transactions submitted for publication in L1.",
}, []string{labelNameChain}),
ncTXPublishResult: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "node_conn",
Name: "tx_publish_result",
Help: "The duration (s) to publish a transaction.",
Buckets: postTimeBuckets,
}, []string{labelNameChain, labelTxPublishResult}),
//
// webapi
//
webAPIRequests: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "webapi",
Name: "webapi_requests",
Help: "Time elapsed (s) processing requests",
Buckets: execTimeBuckets,
}, []string{labelNameChain, labelNameWebapiRequestOperation, labelNameWebapiRequestStatusCode}),
webAPIEvmRPCCalls: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "iota_wasp",
Subsystem: "webapi",
Name: "webapi_evm_rpc_calls",
Help: "Time elapsed (s) processing evm rpc requests",
Buckets: execTimeBuckets,
}, []string{labelNameChain, labelNameWebapiRequestOperation, labelNameWebapiEvmRPCSuccess}),
}
m.inMilestoneMetrics = newMessageMetric[*nodeclient.MilestoneInfo](m, labelNameInMilestone)
m.inStateOutputMetrics = newMessageMetric[*InStateOutput](m, labelNameInStateOutputMetrics)
m.inAliasOutputMetrics = newMessageMetric[*iotago.AliasOutput](m, labelNameInAliasOutputMetrics)
m.inOutputMetrics = newMessageMetric[*InOutput](m, labelNameInOutputMetrics)
m.inOnLedgerRequestMetrics = newMessageMetric[isc.OnLedgerRequest](m, labelNameInOnLedgerRequestMetrics)
m.inTxInclusionStateMetrics = newMessageMetric[*TxInclusionStateMsg](m, labelNameInTxInclusionStateMetrics)
m.outPublishStateTransactionMetrics = newMessageMetric[*StateTransaction](m, labelNameOutPublishStateTransactionMetrics)
m.outPublishGovernanceTransactionMetrics = newMessageMetric[*iotago.Transaction](m, labelNameOutPublishGovernanceTransactionMetrics)
m.outPullLatestOutputMetrics = newMessageMetric[interface{}](m, labelNameOutPullLatestOutputMetrics)
m.outPullTxInclusionStateMetrics = newMessageMetric[iotago.TransactionID](m, labelNameOutPullTxInclusionStateMetrics)
m.outPullOutputByIDMetrics = newMessageMetric[iotago.OutputID](m, labelNameOutPullOutputByIDMetrics)
return m
}
func (m *ChainMetricsProvider) GetChainMetrics(chainID isc.ChainID) IChainMetrics {
m.chainsLock.Lock()
defer m.chainsLock.Unlock()
if cm, ok := m.chainsRegistered[chainID]; ok {
return cm
}
cm := newChainMetrics(m, chainID)
m.chainsRegistered[chainID] = cm
return cm
}
func (m *ChainMetricsProvider) PrometheusCollectorsBlockWAL() []prometheus.Collector {
return []prometheus.Collector{
m.blockWALFailedWrites,
m.blockWALFailedReads,
m.blockWALBlocksAdded,
m.blockWALMaxBlockIndex,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsConsensus() []prometheus.Collector {
return []prometheus.Collector{
m.consensusVMRunTime,
m.consensusVMRunTimePerReq,
m.consensusVMRunReqCount,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsMempool() []prometheus.Collector {
return []prometheus.Collector{
m.blocksTotalPerChain,
m.requestsReceivedOffLedger,
m.requestsReceivedOnLedger,
m.requestsProcessed,
m.requestsAckMessages,
m.requestsProcessingTime,
m.mempoolTimePoolSize,
m.mempoolOnLedgerPoolSize,
m.mempoolOnLedgerReqTime,
m.mempoolOffLedgerPoolSize,
m.mempoolOffLedgerReqTime,
m.mempoolTotalSize,
m.mempoolMissingReqs,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsChainMessages() []prometheus.Collector {
return []prometheus.Collector{
m.messagesL1,
m.lastL1MessageTime,
m.messagesL1Chain,
m.lastL1MessageTimeChain,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsChainState() []prometheus.Collector {
return []prometheus.Collector{
m.chainActiveStateWant,
m.chainActiveStateHave,
m.chainConfirmedStateWant,
m.chainConfirmedStateHave,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsChainStateManager() []prometheus.Collector {
return []prometheus.Collector{
m.smCacheSize,
m.smBlocksFetching,
m.smBlocksPending,
m.smBlocksCommitted,
m.smRequestsWaiting,
m.smCSPHandlingDuration,
m.smCDSHandlingDuration,
m.smCBPHandlingDuration,
m.smFSDHandlingDuration,
m.smTTHandlingDuration,
m.smBlockFetchDuration,
}
}
func (m *ChainMetricsProvider) PrometheusCollectorsChainNodeConn() []prometheus.Collector {
return []prometheus.Collector{
m.ncL1RequestReceived,
m.ncL1AliasOutputReceived,
m.ncTXPublishStarted,
m.ncTXPublishResult,
}
}
func (m *ChainMetricsProvider) PrometheusRegisterChainPipeMetrics(reg *prometheus.Registry) {
m.pipeLenRegistry = reg
}
func (m *ChainMetricsProvider) PrometheusCollectorsWebAPI() []prometheus.Collector {
return []prometheus.Collector{
m.webAPIRequests,
m.webAPIEvmRPCCalls,
}
}
func (m *ChainMetricsProvider) RegisterChain(chainID isc.ChainID) {
m.GetChainMetrics(chainID)
}
func (m *ChainMetricsProvider) UnregisterChain(chainID isc.ChainID) {
m.chainsLock.Lock()
defer m.chainsLock.Unlock()
if cm, ok := m.chainsRegistered[chainID]; ok {
cm.cleanup()
delete(m.chainsRegistered, chainID)
}
}
func (m *ChainMetricsProvider) RegisteredChains() []isc.ChainID {
m.chainsLock.RLock()
defer m.chainsLock.RUnlock()
return lo.Keys(m.chainsRegistered)
}
func (m *ChainMetricsProvider) InMilestone() IMessageMetric[*nodeclient.MilestoneInfo] {
return m.inMilestoneMetrics
}
func (m *ChainMetricsProvider) InStateOutput() IMessageMetric[*InStateOutput] {
return m.inStateOutputMetrics
}
func (m *ChainMetricsProvider) InAliasOutput() IMessageMetric[*iotago.AliasOutput] {
return m.inAliasOutputMetrics
}
func (m *ChainMetricsProvider) InOutput() IMessageMetric[*InOutput] {
return m.inOutputMetrics
}
func (m *ChainMetricsProvider) InOnLedgerRequest() IMessageMetric[isc.OnLedgerRequest] {
return m.inOnLedgerRequestMetrics
}
func (m *ChainMetricsProvider) InTxInclusionState() IMessageMetric[*TxInclusionStateMsg] {
return m.inTxInclusionStateMetrics
}
func (m *ChainMetricsProvider) OutPublishStateTransaction() IMessageMetric[*StateTransaction] {
return m.outPublishStateTransactionMetrics
}
func (m *ChainMetricsProvider) OutPublishGovernanceTransaction() IMessageMetric[*iotago.Transaction] {
return m.outPublishGovernanceTransactionMetrics
}
func (m *ChainMetricsProvider) OutPullLatestOutput() IMessageMetric[interface{}] {
return m.outPullLatestOutputMetrics
}
func (m *ChainMetricsProvider) OutPullTxInclusionState() IMessageMetric[iotago.TransactionID] {
return m.outPullTxInclusionStateMetrics
}
func (m *ChainMetricsProvider) OutPullOutputByID() IMessageMetric[iotago.OutputID] {
return m.outPullOutputByIDMetrics
}