iota_core/traffic_controller/
metrics.rs1use prometheus::{
6 IntCounter, IntCounterVec, IntGauge, Registry, register_int_counter_vec_with_registry,
7 register_int_counter_with_registry, register_int_gauge_with_registry,
8};
9
10#[derive(Clone)]
11pub struct TrafficControllerMetrics {
12 pub tallies: IntCounter,
13 pub connection_ip_blocklist_len: IntGauge,
14 pub proxy_ip_blocklist_len: IntGauge,
15 pub requests_blocked_at_protocol: IntCounter,
16 pub blocks_delegated_to_firewall: IntCounter,
17 pub firewall_delegation_request_fail: IntCounter,
18 pub tally_channel_overflow: IntCounter,
19 pub num_dry_run_blocked_requests: IntCounter,
20 pub tally_handled: IntCounter,
21 pub error_tally_handled: IntCounter,
22 pub tally_error_types: IntCounterVec,
23 pub deadmans_switch_enabled: IntGauge,
24 pub highest_direct_spam_rate: IntGauge,
25 pub highest_proxied_spam_rate: IntGauge,
26 pub highest_direct_error_rate: IntGauge,
27 pub highest_proxied_error_rate: IntGauge,
28 pub spam_client_threshold: IntGauge,
29 pub error_client_threshold: IntGauge,
30 pub spam_proxied_client_threshold: IntGauge,
31 pub error_proxied_client_threshold: IntGauge,
32 pub dry_run_enabled: IntGauge,
33}
34
35impl TrafficControllerMetrics {
36 pub fn new(registry: &Registry) -> Self {
37 Self {
38 tallies: register_int_counter_with_registry!("tallies", "Number of tallies", registry)
39 .unwrap(),
40 connection_ip_blocklist_len: register_int_gauge_with_registry!(
41 "connection_ip_blocklist_len",
42 "Number of connection IP addresses (IP addresses as registered \
44 via direct socket connection to the reporting node) in the \
45 protocol layer blocklist",
46 registry
47 )
48 .unwrap(),
49 proxy_ip_blocklist_len: register_int_gauge_with_registry!(
50 "proxy_ip_blocklist_len",
51 "Number of proxy IP addresses (IP addresses as collected \
53 via some mechanism through proxy node such as fullnode) \
54 in the protocol layer blocklist",
55 registry
56 )
57 .unwrap(),
58 requests_blocked_at_protocol: register_int_counter_with_registry!(
59 "requests_blocked_at_protocol",
60 "Number of requests blocked by this node at the protocol level",
61 registry
62 )
63 .unwrap(),
64 blocks_delegated_to_firewall: register_int_counter_with_registry!(
65 "blocks_delegated_to_firewall",
66 "Number of delegation requests to firewall to add to blocklist",
67 registry
68 )
69 .unwrap(),
70 firewall_delegation_request_fail: register_int_counter_with_registry!(
71 "firewall_delegation_request_fail",
72 "Number of failed http requests to firewall for blocklist delegation",
73 registry
74 )
75 .unwrap(),
76 tally_channel_overflow: register_int_counter_with_registry!(
77 "tally_channel_overflow",
78 "Traffic controller tally channel overflow count",
79 registry
80 )
81 .unwrap(),
82 num_dry_run_blocked_requests: register_int_counter_with_registry!(
83 "traffic_control_num_dry_run_blocked_requests",
84 "Number of requests blocked in traffic controller dry run mode",
85 registry
86 )
87 .unwrap(),
88 tally_handled: register_int_counter_with_registry!(
89 "traffic_control_tally_handled",
90 "Number of tallies handled",
91 registry
92 )
93 .unwrap(),
94 error_tally_handled: register_int_counter_with_registry!(
95 "traffic_control_error_tally_handled",
96 "Number of error tallies handled",
97 registry
98 )
99 .unwrap(),
100 tally_error_types: register_int_counter_vec_with_registry!(
101 "traffic_control_tally_error_types",
102 "Number of tally errors, grouped by error type",
103 &["error_type"],
104 registry
105 )
106 .unwrap(),
107 deadmans_switch_enabled: register_int_gauge_with_registry!(
108 "deadmans_switch_enabled",
109 "If 1, the deadman's switch is enabled and all traffic control
110 should be getting bypassed",
111 registry
112 )
113 .unwrap(),
114 highest_direct_spam_rate: register_int_gauge_with_registry!(
115 "highest_direct_spam_rate",
116 "Highest direct spam rate seen recently",
117 registry
118 )
119 .unwrap(),
120 highest_proxied_spam_rate: register_int_gauge_with_registry!(
121 "highest_proxied_spam_rate",
122 "Highest proxied spam rate seen recently",
123 registry
124 )
125 .unwrap(),
126 highest_direct_error_rate: register_int_gauge_with_registry!(
127 "highest_direct_error_rate",
128 "Highest direct error rate seen recently",
129 registry
130 )
131 .unwrap(),
132 highest_proxied_error_rate: register_int_gauge_with_registry!(
133 "highest_proxied_error_rate",
134 "Highest proxied error rate seen recently",
135 registry
136 )
137 .unwrap(),
138 spam_client_threshold: register_int_gauge_with_registry!(
139 "spam_client_threshold",
140 "Spam client threshold",
141 registry
142 )
143 .unwrap(),
144 error_client_threshold: register_int_gauge_with_registry!(
145 "error_client_threshold",
146 "Error client threshold",
147 registry
148 )
149 .unwrap(),
150 spam_proxied_client_threshold: register_int_gauge_with_registry!(
151 "spam_proxied_client_threshold",
152 "Spam proxied client threshold",
153 registry
154 )
155 .unwrap(),
156 error_proxied_client_threshold: register_int_gauge_with_registry!(
157 "error_proxied_client_threshold",
158 "Error proxied client threshold",
159 registry
160 )
161 .unwrap(),
162 dry_run_enabled: register_int_gauge_with_registry!(
163 "dry_run_enabled",
164 "If 1, dry run mode is enabled and traffic will not be blocked",
165 registry
166 )
167 .unwrap(),
168 }
169 }
170
171 pub fn new_for_tests() -> Self {
172 Self::new(&Registry::new())
173 }
174}