sui_bridge/sui_bridge_watchdog/
metrics.rs1use prometheus::{
5 IntGauge, IntGaugeVec, Registry, register_int_gauge_vec_with_registry,
6 register_int_gauge_with_registry,
7};
8
9#[derive(Clone, Debug)]
10pub struct WatchdogMetrics {
11 pub eth_vault_balance: IntGauge,
12 pub usdt_vault_balance: IntGauge,
13 pub wbtc_vault_balance: IntGauge,
14 pub lbtc_vault_balance: IntGauge,
15 pub total_supplies: IntGaugeVec,
16 pub eth_bridge_paused: IntGauge,
17 pub sui_bridge_paused: IntGauge,
18}
19
20impl WatchdogMetrics {
21 pub fn new(registry: &Registry) -> Self {
22 Self {
23 eth_vault_balance: register_int_gauge_with_registry!(
24 "bridge_eth_vault_balance",
25 "Current balance of eth vault",
26 registry,
27 )
28 .unwrap(),
29 usdt_vault_balance: register_int_gauge_with_registry!(
30 "bridge_usdt_vault_balance",
31 "Current balance of usdt eth vault",
32 registry,
33 )
34 .unwrap(),
35 wbtc_vault_balance: register_int_gauge_with_registry!(
36 "bridge_wbtc_vault_balance",
37 "Current balance of wbtc eth vault",
38 registry,
39 )
40 .unwrap(),
41 lbtc_vault_balance: register_int_gauge_with_registry!(
42 "bridge_lbtc_vault_balance",
43 "Current balance of lbtc eth vault",
44 registry,
45 )
46 .unwrap(),
47 total_supplies: register_int_gauge_vec_with_registry!(
48 "bridge_total_supplies",
49 "Current total supplies of coins on Sui based on Treasury Cap",
50 &["token_name"],
51 registry,
52 )
53 .unwrap(),
54 eth_bridge_paused: register_int_gauge_with_registry!(
55 "bridge_eth_bridge_paused",
56 "Whether the eth bridge is paused",
57 registry,
58 )
59 .unwrap(),
60 sui_bridge_paused: register_int_gauge_with_registry!(
61 "bridge_sui_bridge_paused",
62 "Whether the sui bridge is paused",
63 registry,
64 )
65 .unwrap(),
66 }
67 }
68
69 pub fn new_for_testing() -> Self {
70 let registry = Registry::new();
71 Self::new(®istry)
72 }
73}