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
use polkadot_runtime_metrics::{Counter, CounterVec};
use primitives::v2::metric_definitions::{
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED,
PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED,
PARACHAIN_INHERENT_DATA_WEIGHT,
};
pub struct Metrics {
inherent_data_weight: CounterVec,
bitfields_processed: Counter,
candidates_processed: CounterVec,
dispute_sets_processed: CounterVec,
disputes_included: Counter,
bitfields_signature_checks: CounterVec,
}
impl Metrics {
pub fn on_before_filter(&self, value: u64) {
self.inherent_data_weight.with_label_values(&["before-filter"]).inc_by(value);
}
pub fn on_after_filter(&self, value: u64) {
self.inherent_data_weight.with_label_values(&["after-filter"]).inc_by(value);
}
pub fn on_bitfields_processed(&self, value: u64) {
self.bitfields_processed.inc_by(value);
}
pub fn on_candidates_included(&self, value: u64) {
self.candidates_processed.with_label_values(&["included"]).inc_by(value);
}
pub fn on_candidates_sanitized(&self, value: u64) {
self.candidates_processed.with_label_values(&["sanitized"]).inc_by(value);
}
pub fn on_candidates_processed_total(&self, value: u64) {
self.candidates_processed.with_label_values(&["total"]).inc_by(value);
}
pub fn on_relay_chain_freeze(&self) {
self.dispute_sets_processed.with_label_values(&["frozen"]).inc();
}
pub fn on_current_session_disputes_processed(&self, value: u64) {
self.dispute_sets_processed.with_label_values(&["current"]).inc_by(value);
}
pub fn on_disputes_concluded_invalid(&self, value: u64) {
self.dispute_sets_processed
.with_label_values(&["concluded_invalid"])
.inc_by(value);
}
pub fn on_disputes_imported(&self, value: u64) {
self.dispute_sets_processed.with_label_values(&["imported"]).inc_by(value);
}
pub fn on_disputes_included(&self, value: u64) {
self.disputes_included.inc_by(value);
}
pub fn on_valid_bitfield_signature(&self) {
self.bitfields_signature_checks.with_label_values(&["valid"]).inc();
}
pub fn on_invalid_bitfield_signature(&self) {
self.bitfields_signature_checks.with_label_values(&["invalid"]).inc();
}
}
pub const METRICS: Metrics = Metrics {
inherent_data_weight: CounterVec::new(PARACHAIN_INHERENT_DATA_WEIGHT),
bitfields_processed: Counter::new(PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED),
candidates_processed: CounterVec::new(PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED),
dispute_sets_processed: CounterVec::new(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED),
disputes_included: Counter::new(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED),
bitfields_signature_checks: CounterVec::new(
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
),
};