cat_gateway/metrics/chain_follower/
reporter.rs1use std::sync::LazyLock;
5
6use prometheus::{register_int_gauge_vec, IntGaugeVec};
7
8const FOLLOWER_METRIC_LABELS: [&str; 3] = ["api_host_names", "service_id", "network"];
10
11pub(super) static MITHRIL_UPDATES: LazyLock<IntGaugeVec> = LazyLock::new(|| {
15    register_int_gauge_vec!(
16        format!("follower_mithril_updates"),
17        "Number of Mithril Snapshots that have downloaded successfully",
18        &FOLLOWER_METRIC_LABELS
19    )
20    .unwrap()
21});
22
23pub(super) static MITHRIL_TIP: LazyLock<IntGaugeVec> = LazyLock::new(|| {
25    register_int_gauge_vec!(
26        format!("follower_mithril_tip"),
27        "Immutable TIP Slot#",
28        &FOLLOWER_METRIC_LABELS
29    )
30    .unwrap()
31});
32
33pub(super) static MITHRIL_DL_START: LazyLock<IntGaugeVec> = LazyLock::new(|| {
35    register_int_gauge_vec!(
36        format!("follower_mithril_dl_start"),
37        "Time we started downloading the current snapshot (UNIX timestamp)",
38        &FOLLOWER_METRIC_LABELS
39    )
40    .unwrap()
41});
42
43pub(super) static MITHRIL_DL_END: LazyLock<IntGaugeVec> = LazyLock::new(|| {
45    register_int_gauge_vec!(
46        format!("follower_mithril_dl_end"),
47        "Time we finished downloading the current snapshot (UNIX timestamp)",
48        &FOLLOWER_METRIC_LABELS
49    )
50    .unwrap()
51});
52
53pub(super) static MITHRIL_DL_FAILURES: LazyLock<IntGaugeVec> = LazyLock::new(|| {
55    register_int_gauge_vec!(
56        format!("follower_mithril_dl_failures"),
57        "Number of times download failed",
58        &FOLLOWER_METRIC_LABELS
59    )
60    .unwrap()
61});
62
63pub(super) static MITHRIL_LAST_DL_DURATION: LazyLock<IntGaugeVec> = LazyLock::new(|| {
65    register_int_gauge_vec!(
66        format!("follower_mithril_last_dl_duration"),
67        "Time the last download took (seconds)",
68        &FOLLOWER_METRIC_LABELS
69    )
70    .unwrap()
71});
72
73pub(super) static MITHRIL_DL_SIZE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
75    register_int_gauge_vec!(
76        format!("follower_mithril_dl_size"),
77        "Size of the download archive (bytes)",
78        &FOLLOWER_METRIC_LABELS
79    )
80    .unwrap()
81});
82
83pub(super) static MITHRIL_EXTRACT_FAILURES: LazyLock<IntGaugeVec> = LazyLock::new(|| {
85    register_int_gauge_vec!(
86        format!("follower_mithril_extract_failures"),
87        "Number of times extraction failed",
88        &FOLLOWER_METRIC_LABELS
89    )
90    .unwrap()
91});
92
93pub(super) static MITHRIL_EXTRACT_START: LazyLock<IntGaugeVec> = LazyLock::new(|| {
95    register_int_gauge_vec!(
96        format!("follower_mithril_extract_start"),
97        "Extraction start time (UNIX timestamp)",
98        &FOLLOWER_METRIC_LABELS
99    )
100    .unwrap()
101});
102
103pub(super) static MITHRIL_EXTRACT_END: LazyLock<IntGaugeVec> = LazyLock::new(|| {
105    register_int_gauge_vec!(
106        format!("follower_mithril_extract_end"),
107        "Extraction end time (UNIX timestamp)",
108        &FOLLOWER_METRIC_LABELS
109    )
110    .unwrap()
111});
112
113pub(super) static MITHRIL_EXTRACT_SIZE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
115    register_int_gauge_vec!(
116        format!("follower_mithril_extract_size"),
117        "Size of last extracted snapshot (bytes)",
118        &FOLLOWER_METRIC_LABELS
119    )
120    .unwrap()
121});
122
123pub(super) static MITHRIL_DEDUPLICATED_SIZE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
125    register_int_gauge_vec!(
126        format!("follower_mithril_deduplicated_size"),
127        "Deduplicated Size vs previous snapshot",
128        &FOLLOWER_METRIC_LABELS
129    )
130    .unwrap()
131});
132
133pub(super) static MITHRIL_DEDUPLICATED: LazyLock<IntGaugeVec> = LazyLock::new(|| {
135    register_int_gauge_vec!(
136        format!("follower_mithril_deduplicated"),
137        "Number of identical files deduplicated from previous snapshot",
138        &FOLLOWER_METRIC_LABELS
139    )
140    .unwrap()
141});
142
143pub(super) static MITHRIL_CHANGED: LazyLock<IntGaugeVec> = LazyLock::new(|| {
145    register_int_gauge_vec!(
146        format!("follower_mithril_changed"),
147        "Number of changed files from previous snapshot",
148        &FOLLOWER_METRIC_LABELS
149    )
150    .unwrap()
151});
152
153pub(super) static MITHRIL_NEW: LazyLock<IntGaugeVec> = LazyLock::new(|| {
155    register_int_gauge_vec!(
156        format!("follower_mithril_new"),
157        "Number of new files from previous snapshot",
158        &FOLLOWER_METRIC_LABELS
159    )
160    .unwrap()
161});
162
163pub(super) static MITHRIL_VALIDATE_START: LazyLock<IntGaugeVec> = LazyLock::new(|| {
165    register_int_gauge_vec!(
166        format!("follower_mithril_validate_start"),
167        "Mithril Certificate Validation Start Time (UNIX timestamp)",
168        &FOLLOWER_METRIC_LABELS
169    )
170    .unwrap()
171});
172
173pub(super) static MITHRIL_VALIDATE_END: LazyLock<IntGaugeVec> = LazyLock::new(|| {
175    register_int_gauge_vec!(
176        format!("follower_mithril_validate_end"),
177        "Mithril Certificate Validation End Time (UNIX timestamp)",
178        &FOLLOWER_METRIC_LABELS
179    )
180    .unwrap()
181});
182
183pub(super) static MITHRIL_VALIDATE_FAILURES: LazyLock<IntGaugeVec> = LazyLock::new(|| {
185    register_int_gauge_vec!(
186        format!("follower_mithril_validate_failures"),
187        "Number of times validation failed (bad snapshot)",
188        &FOLLOWER_METRIC_LABELS
189    )
190    .unwrap()
191});
192
193pub(super) static MITHRIL_INVALID_BLOCKS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
195    register_int_gauge_vec!(
196        format!("follower_mithril_invalid_blocks"),
197        "Blocks that failed to deserialize from the Mithril immutable chain",
198        &FOLLOWER_METRIC_LABELS
199    )
200    .unwrap()
201});
202
203pub(super) static MITHRIL_DOWNLOAD_OR_VALIDATION_FAILED: LazyLock<IntGaugeVec> =
205    LazyLock::new(|| {
206        register_int_gauge_vec!(
207            format!("follower_mithril_download_or_validation_failed"),
208            "Download or Validation Failed",
209            &FOLLOWER_METRIC_LABELS
210        )
211        .unwrap()
212    });
213
214pub(super) static MITHRIL_FAILED_TO_GET_TIP: LazyLock<IntGaugeVec> = LazyLock::new(|| {
216    register_int_gauge_vec!(
217        format!("follower_mithril_failed_to_get_tip"),
218        "Failed to get tip from Mithril snapshot",
219        &FOLLOWER_METRIC_LABELS
220    )
221    .unwrap()
222});
223
224pub(super) static MITHRIL_TIP_DID_NOT_ADVANCE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
226    register_int_gauge_vec!(
227        format!("follower_mithril_tip_did_not_advance"),
228        "Tip failed to advance",
229        &FOLLOWER_METRIC_LABELS
230    )
231    .unwrap()
232});
233
234pub(super) static MITHRIL_TIP_FAILED_TO_SEND_TO_UPDATER: LazyLock<IntGaugeVec> =
236    LazyLock::new(|| {
237        register_int_gauge_vec!(
238            format!("follower_mithril_tip_failed_to_send_to_updater"),
239            "Failed to send new tip to updater",
240            &FOLLOWER_METRIC_LABELS
241        )
242        .unwrap()
243    });
244
245pub(super) static MITHRIL_FAILED_TO_ACTIVATE_NEW_SNAPSHOT: LazyLock<IntGaugeVec> =
247    LazyLock::new(|| {
248        register_int_gauge_vec!(
249            format!("follower_mithril_failed_to_activate_new_snapshot"),
250            "Failed to activate new snapshot",
251            &FOLLOWER_METRIC_LABELS
252        )
253        .unwrap()
254    });
255
256pub(super) static LIVE_SYNC_START: LazyLock<IntGaugeVec> = LazyLock::new(|| {
260    register_int_gauge_vec!(
261        format!("follower_live_sync_start"),
262        "The Time that synchronization to this blockchain started",
263        &FOLLOWER_METRIC_LABELS
264    )
265    .unwrap()
266});
267
268pub(super) static LIVE_SYNC_END: LazyLock<IntGaugeVec> = LazyLock::new(|| {
271    register_int_gauge_vec!(
272        format!("follower_live_sync_end"),
273        "The Time that synchronization to this blockchain was complete up-to-tip",
274        &FOLLOWER_METRIC_LABELS
275    )
276    .unwrap()
277});
278
279pub(super) static LIVE_BACKFILL_START: LazyLock<IntGaugeVec> = LazyLock::new(|| {
281    register_int_gauge_vec!(
282        format!("follower_live_backfill_start"),
283        "When backfill started",
284        &FOLLOWER_METRIC_LABELS
285    )
286    .unwrap()
287});
288
289pub(super) static LIVE_BACKFILL_SIZE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
291    register_int_gauge_vec!(
292        format!("follower_live_backfill_size"),
293        "Backfill size to achieve synchronization",
294        &FOLLOWER_METRIC_LABELS
295    )
296    .unwrap()
297});
298
299pub(super) static LIVE_BACKFILL_END: LazyLock<IntGaugeVec> = LazyLock::new(|| {
301    register_int_gauge_vec!(
302        format!("follower_live_backfill_end"),
303        "When backfill ended",
304        &FOLLOWER_METRIC_LABELS
305    )
306    .unwrap()
307});
308
309pub(super) static LIVE_BACKFILL_FAILURES: LazyLock<IntGaugeVec> = LazyLock::new(|| {
311    register_int_gauge_vec!(
312        format!("follower_live_backfill_failures"),
313        "Backfill Failures",
314        &FOLLOWER_METRIC_LABELS
315    )
316    .unwrap()
317});
318
319pub(super) static LIVE_BACKFILL_FAILURE_TIME: LazyLock<IntGaugeVec> = LazyLock::new(|| {
321    register_int_gauge_vec!(
322        format!("follower_live_backfill_failure_time"),
323        "The time of the last backfill failure",
324        &FOLLOWER_METRIC_LABELS
325    )
326    .unwrap()
327});
328
329pub(super) static LIVE_BLOCKS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
331    register_int_gauge_vec!(
332        format!("follower_live_blocks"),
333        "Current Number of Live Blocks",
334        &FOLLOWER_METRIC_LABELS
335    )
336    .unwrap()
337});
338
339pub(super) static LIVE_HEAD_SLOT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
341    register_int_gauge_vec!(
342        format!("follower_live_head_slot"),
343        "The current head of the live chain slot#",
344        &FOLLOWER_METRIC_LABELS
345    )
346    .unwrap()
347});
348
349pub(super) static LIVE_TIP: LazyLock<IntGaugeVec> = LazyLock::new(|| {
351    register_int_gauge_vec!(
352        format!("follower_live_tip"),
353        "The current live tip slot# as reported by the peer",
354        &FOLLOWER_METRIC_LABELS
355    )
356    .unwrap()
357});
358
359pub(super) static LIVE_RECONNECTS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
361    register_int_gauge_vec!(
362        format!("follower_live_reconnects"),
363        "Number of times we connected/re-connected to the Node",
364        &FOLLOWER_METRIC_LABELS
365    )
366    .unwrap()
367});
368
369pub(super) static LIVE_LAST_CONNECT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
371    register_int_gauge_vec!(
372        format!("follower_live_last_connect"),
373        "Last reconnect time",
374        &FOLLOWER_METRIC_LABELS
375    )
376    .unwrap()
377});
378
379pub(super) static LIVE_LAST_DISCONNECT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
381    register_int_gauge_vec!(
382        format!("follower_live_last_disconnect"),
383        "Last disconnect time",
384        &FOLLOWER_METRIC_LABELS
385    )
386    .unwrap()
387});
388
389pub(super) static LIVE_CONNECTED: LazyLock<IntGaugeVec> = LazyLock::new(|| {
391    register_int_gauge_vec!(
392        format!("follower_live_connected"),
393        "Is there an active connection to the node",
394        &FOLLOWER_METRIC_LABELS
395    )
396    .unwrap()
397});
398
399pub(super) static LIVE_ROLLBACKS_LIVE_COUNT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
401    register_int_gauge_vec!(
402        format!("follower_live_rollbacks_live_count"),
403        "Number of live chain rollback",
404        &FOLLOWER_METRIC_LABELS
405    )
406    .unwrap()
407});
408
409pub(super) static LIVE_ROLLBACKS_PEER_COUNT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
411    register_int_gauge_vec!(
412        format!("follower_live_rollbacks_peer_count"),
413        "Number of rollbacks reported by the peer node",
414        &FOLLOWER_METRIC_LABELS
415    )
416    .unwrap()
417});
418
419pub(super) static LIVE_ROLLBACKS_FOLLOWER_COUNT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
421    register_int_gauge_vec!(
422        format!("follower_live_rollbacks_follower_count"),
423        "Number of rollbacks synthesized for followers",
424        &FOLLOWER_METRIC_LABELS
425    )
426    .unwrap()
427});
428
429pub(super) static LIVE_NEW_BLOCKS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
431    register_int_gauge_vec!(
432        format!("follower_live_new_blocks"),
433        "New blocks read from blockchain",
434        &FOLLOWER_METRIC_LABELS
435    )
436    .unwrap()
437});
438
439pub(super) static LIVE_INVALID_BLOCKS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
441    register_int_gauge_vec!(
442        format!("follower_live_invalid_blocks"),
443        "Blocks that failed to deserialize from the blockchain",
444        &FOLLOWER_METRIC_LABELS
445    )
446    .unwrap()
447});
448
449pub(super) static LIVE_FOLLOWER_COUNT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
451    register_int_gauge_vec!(
452        format!("follower_live_follower_count"),
453        "Number of active Followers",
454        &FOLLOWER_METRIC_LABELS
455    )
456    .unwrap()
457});