-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmetrics.py
153 lines (131 loc) · 3.7 KB
/
metrics.py
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
from prometheus_client.metrics import Counter, Gauge, Histogram, Info
from variables import DEPOSIT_MODULES_WHITELIST, PROMETHEUS_PREFIX, PUBLIC_ENV_VARS
GAS_FEE = Gauge(
'gas_fee',
'Gas fee',
['type', 'module_id'],
namespace=PROMETHEUS_PREFIX,
)
TX_SEND = Counter('transactions_send', 'Amount of send transaction from bot.', ['status'], namespace=PROMETHEUS_PREFIX)
# Initialize metrics
TX_SEND.labels('success').inc(0)
TX_SEND.labels('failure').inc(0)
MODULE_TX_SEND = Counter(
'transactions',
'Amount of send transactions from depositor bot.',
['status', 'module_id'],
namespace=PROMETHEUS_PREFIX,
)
DEPOSIT_MESSAGES = Gauge(
'deposit_messages',
'Guardians deposit messages',
['address', 'module_id', 'version', 'transport', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
PAUSE_MESSAGES = Gauge(
'pause_messages',
'Guardians pause messages',
['address', 'module_id', 'version', 'transport', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
PING_MESSAGES = Gauge(
'ping_messages',
'Guardians ping messages',
['address', 'version', 'transport', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
UNVET_MESSAGES = Gauge(
'unvet_messages',
'Guardian unvet messages',
['address', 'module_id', 'version', 'transport', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
CURRENT_QUORUM_SIZE = Gauge(
'quorum_size',
'Current quorum size',
['type'],
namespace=PROMETHEUS_PREFIX,
)
DEPOSITABLE_ETHER = Gauge(
'depositable_ether',
'Depositable Ether',
namespace=PROMETHEUS_PREFIX,
)
POSSIBLE_DEPOSITS_AMOUNT = Gauge(
'possible_deposits_amount',
'Possible deposits amount.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
IS_DEPOSITABLE = Gauge(
'is_depositable',
'Represents is_depositable check.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
QUORUM = Gauge(
'quorum',
'Represents if quorum could be collected.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
CAN_DEPOSIT = Gauge(
'can_deposit',
'Represents can_deposit check.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
GAS_OK = Gauge(
'is_gas_ok',
'Represents is_gas_ok check.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
DEPOSIT_AMOUNT_OK = Gauge(
'is_deposit_amount_ok',
'Represents is_deposit_amount_ok check.',
['module_id'],
namespace=PROMETHEUS_PREFIX,
)
ETH_RPC_REQUESTS_DURATION = Histogram(
'eth_rpc_requests_duration',
'Duration of requests to ETH1 RPC',
namespace=PROMETHEUS_PREFIX,
)
ETH_RPC_REQUESTS = Counter(
'eth_rpc_requests',
'Total count of requests to ETH1 RPC',
['method', 'code', 'domain'],
namespace=PROMETHEUS_PREFIX,
)
ONCHAIN_TRANSPORT_ETH_RPC_REQUESTS = Counter(
'onchain_transport_rpc_requests',
'Total count of requests to onchain transport RPC',
['method', 'code', 'domain'],
namespace=PROMETHEUS_PREFIX,
)
UNEXPECTED_EXCEPTIONS = Counter(
'unexpected_exceptions',
'Total count of unexpected exceptions',
['type'],
namespace=PROMETHEUS_PREFIX,
)
# TODO unify ACCOUNT_BALANCE and GUARDIAN_BALANCE
ACCOUNT_BALANCE = Gauge(
'account_balance',
'Account balance',
['address', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
GUARDIAN_BALANCE = Gauge(
'guardian_balance',
'Balance of the guardian',
['address', 'chain_id'],
namespace=PROMETHEUS_PREFIX,
)
MODULES = Gauge('modules', 'Modules gauge', ['module_id'], namespace=PROMETHEUS_PREFIX)
for module_id in DEPOSIT_MODULES_WHITELIST:
MODULES.labels(module_id).set(1)
INFO = Info(name='build', documentation='Info metric', namespace=PROMETHEUS_PREFIX)
CONVERTED_PUBLIC_ENV = {k: str(v) for k, v in PUBLIC_ENV_VARS.items()}
INFO.info(CONVERTED_PUBLIC_ENV)