1use metrics::{describe_counter, describe_gauge, describe_histogram, Unit};
7
8pub const LABELS: &[(&str, &[&str])] = &[
36 ("zebrad.build.info", &["version", "commit"]),
37 ("sync.restart.count", &["reason", "made_progress"]),
38 ("sync.block.error.count", &["kind"]),
39 ("sync.block.download.duration_seconds", &["result"]),
40 ("sync.block.verify.duration_seconds", &["result"]),
41 ("sync.stage.duration_seconds", &["stage"]),
42 ("mempool.failed.verify.tasks.total", &["reason"]),
43 ("mempool.downloaded.transactions.total", &["version"]),
44 ("mempool.pushed.transactions.total", &["version"]),
45 ("mempool.verified.transactions.total", &["version"]),
46 ("zcash.mempool.actions.unpaid", &["bk"]),
47 ("zcash.mempool.size.weighted", &["bk"]),
48 (
49 "zcash.chain.tip.block_delay_seconds",
50 &["chain.network_upgrade"],
51 ),
52 ("zebrad.sentry.metrics.dropped.total", &["reason"]),
53 ("sync.mined.block.announcement.outcomes.total", &["outcome"]),
54];
55
56pub fn describe() {
58 describe_counter!(
59 concat!(env!("CARGO_PKG_NAME"), ".build.info"),
60 Unit::Count,
61 "Always 1, with the running zebrad version and git commit as labels."
62 );
63 describe_counter!(
64 "zebrad.sentry.metrics.dropped.total",
65 Unit::Count,
66 "Metric values that weren't sent to Sentry when due, because a flush was full, the Sentry \
67 transport was still sending earlier data, or the metric had too many label sets."
68 );
69
70 describe_gauge!(
71 "process.memory.rss_bytes",
72 Unit::Bytes,
73 "Memory zebrad is using, its resident set size. Only recorded on Linux."
74 );
75 describe_gauge!(
76 "process.memory.rss_fraction",
77 Unit::Count,
78 "process.memory.rss_bytes as a fraction of the memory zebrad can use: the tightest \
79 cgroup memory limit, or the machine's memory if that is smaller."
80 );
81
82 describe_sync();
83 describe_gossip();
84 describe_mempool();
85
86 describe_gauge!(
88 "zcashd.compat.supervisor.active",
89 Unit::Count,
90 "1 while zebrad is supervising a zcashd child process, otherwise 0."
91 );
92 describe_gauge!(
93 "zcashd.compat.supervisor.disabled",
94 Unit::Count,
95 "1 when zcashd supervision is turned off or has stopped, otherwise 0."
96 );
97 describe_gauge!(
98 "zcashd.compat.supervisor.exhausted",
99 Unit::Count,
100 "1 when zcashd supervision stopped after too many restarts, otherwise 0."
101 );
102}
103
104fn describe_sync() {
106 describe_histogram!(
107 "sync.mined.block.announcement.duration_seconds",
108 Unit::Seconds,
109 "Time from a mined block's acceptance until its announcement to peers finished."
110 );
111 describe_counter!(
112 "sync.mined.block.announcement.outcomes.total",
113 Unit::Count,
114 "Announcements of mined blocks to peers, by whether they finished or failed."
115 );
116 describe_counter!(
117 "sync.restart.count",
118 Unit::Count,
119 "Sync rounds that ended, by why they ended and whether the state tip advanced."
120 );
121 describe_counter!(
122 "sync.block.error.count",
123 Unit::Count,
124 "Block download and verify errors, by kind."
125 );
126 describe_histogram!(
127 "sync.stage.duration_seconds",
128 Unit::Seconds,
129 "Time taken by each stage of a sync round."
130 );
131 describe_histogram!(
132 "sync.obtain.response.hash.count",
133 Unit::Count,
134 "Block hashes in each peer response while obtaining tips."
135 );
136 describe_gauge!(
137 "sync.obtain.queued.hash.count",
138 Unit::Count,
139 "Block hashes queued for download after obtaining tips."
140 );
141 describe_histogram!(
142 "sync.extend.response.hash.count",
143 Unit::Count,
144 "Block hashes in each peer response while extending tips."
145 );
146 describe_gauge!(
147 "sync.extend.queued.hash.count",
148 Unit::Count,
149 "Block hashes queued for download after extending tips."
150 );
151 describe_gauge!(
152 "sync.prospective_tips.len",
153 Unit::Count,
154 "Chain tips the syncer is following."
155 );
156 describe_gauge!(
157 "sync.downloads.in_flight",
158 Unit::Count,
159 "Blocks the syncer is downloading or verifying."
160 );
161 describe_gauge!(
162 "sync.downloads.oldest_age_seconds",
163 Unit::Seconds,
164 "How long the oldest block still being downloaded or verified has waited, or 0 when none are."
165 );
166 describe_gauge!(
167 "sync.estimated_network_tip_height",
168 Unit::Count,
169 "Estimated height of the network's chain tip."
170 );
171 describe_gauge!(
172 "sync.estimated_distance_to_tip",
173 Unit::Count,
174 "Estimated number of blocks between the state tip and the network's chain tip."
175 );
176 describe_histogram!(
177 "zcash.chain.tip.block_delay_seconds",
178 Unit::Seconds,
179 "Time from a block's header time until it became this node's best chain tip."
180 );
181
182 describe_histogram!(
184 "sync.block.download.duration_seconds",
185 Unit::Seconds,
186 "Time taken to download a block during sync."
187 );
188 describe_histogram!(
189 "sync.block.verify.duration_seconds",
190 Unit::Seconds,
191 "Time taken to verify a downloaded block during sync."
192 );
193 describe_counter!(
194 "sync.downloaded.block.count",
195 Unit::Count,
196 "Blocks downloaded by the syncer."
197 );
198 describe_counter!(
199 "sync.verified.block.count",
200 Unit::Count,
201 "Blocks verified after the syncer downloaded them."
202 );
203 describe_counter!(
204 "sync.already.queued.dropped.block.hash.count",
205 Unit::Count,
206 "Block hashes the syncer ignored because they were already queued for download."
207 );
208 describe_counter!(
209 "sync.already.rejected.dropped.block.hash.count",
210 Unit::Count,
211 "Block hashes the syncer ignored because a compact relay peer already sent that block, \
212 and it failed validation after its early relay checks."
213 );
214 describe_counter!(
215 "sync.no.height.dropped.block.count",
216 Unit::Count,
217 "Downloaded blocks dropped because they have no coinbase height."
218 );
219 describe_counter!(
220 "sync.cancelled.download.count",
221 Unit::Count,
222 "Block downloads cancelled by a sync restart."
223 );
224 describe_counter!(
225 "sync.cancelled.verify.ready.count",
226 Unit::Count,
227 "Block verifications cancelled while waiting for the verifier to be ready."
228 );
229 describe_counter!(
230 "sync.cancelled.verify.count",
231 Unit::Count,
232 "Block verifications cancelled by a sync restart."
233 );
234 describe_counter!(
235 "sync.max.height.limit.paused.count",
236 Unit::Count,
237 "Times downloads paused because the syncer got too far ahead of the state tip."
238 );
239 describe_counter!(
240 "sync.max.height.limit.reset.count",
241 Unit::Count,
242 "Times downloads resumed after the state tip caught up with the syncer."
243 );
244 describe_counter!(
245 "sync.max.height.limit.reset.attempt.count",
246 Unit::Count,
247 "Attempts to resume downloads after the state tip caught up with the syncer."
248 );
249}
250
251fn describe_gossip() {
253 describe_histogram!(
254 "gossip.block.download.duration_seconds",
255 Unit::Seconds,
256 "Time taken to download a gossiped block, from the request to a successful response."
257 );
258 describe_histogram!(
259 "gossip.block.verify_commit.duration_seconds",
260 Unit::Seconds,
261 "Time from sending a downloaded gossiped block to the block verifier until it was \
262 committed."
263 );
264 describe_gauge!(
265 "gossip.queued.block.count",
266 Unit::Count,
267 "Gossiped blocks queued for download and verification."
268 );
269 describe_counter!(
270 "gossip.already.queued.dropped.block.hash.count",
271 Unit::Count,
272 "Gossiped block hashes ignored because they were already queued."
273 );
274 describe_counter!(
275 "gossip.already.rejected.dropped.block.hash.count",
276 Unit::Count,
277 "Gossiped block hashes ignored because a compact relay peer already sent that block, \
278 and it failed validation after its early relay checks."
279 );
280 describe_counter!(
281 "gossip.full.queue.dropped.block.hash.count",
282 Unit::Count,
283 "Gossiped block hashes ignored because the download queue was full."
284 );
285 describe_counter!(
286 "gossip.peer.limit.dropped.block.hash.count",
287 Unit::Count,
288 "Gossiped block hashes ignored because the peer already had a download in progress."
289 );
290 describe_counter!(
291 "gossip.downloaded.block.count",
292 Unit::Count,
293 "Gossiped blocks downloaded."
294 );
295 describe_counter!(
296 "gossip.verified.block.count",
297 Unit::Count,
298 "Gossiped blocks verified."
299 );
300 describe_counter!(
301 "gossip.cancelled.count",
302 Unit::Count,
303 "Gossiped block downloads or verifications cancelled."
304 );
305 describe_counter!(
306 "gossip.no.height.dropped.block.count",
307 Unit::Count,
308 "Gossiped blocks dropped because they have no coinbase height."
309 );
310 describe_counter!(
311 "gossip.max.height.limit.dropped.block.count",
312 Unit::Count,
313 "Gossiped blocks dropped because they are too far above the state tip."
314 );
315 describe_counter!(
316 "gossip.min.height.limit.dropped.block.count",
317 Unit::Count,
318 "Downloaded blocks dropped because they are behind the finalized tip."
319 );
320}
321
322fn describe_mempool() {
324 describe_histogram!(
325 "mempool.tip_cleanup.duration_seconds",
326 Unit::Seconds,
327 "Time taken to remove a new tip block's transactions and their conflicts from the mempool."
328 );
329 describe_histogram!(
330 "mempool.expiry.duration_seconds",
331 Unit::Seconds,
332 "Time taken by each check of the mempool for expired transactions."
333 );
334 describe_gauge!(
335 "mempool.currently.queued.transactions",
336 Unit::Count,
337 "Transactions queued for mempool download and verification."
338 );
339 describe_counter!(
340 "mempool.queued.transactions.total",
341 Unit::Count,
342 "Transactions queued for mempool download and verification."
343 );
344 describe_counter!(
345 "mempool.full_queue.per_peer.total",
346 Unit::Count,
347 "Transactions ignored because their peer already had too many queued."
348 );
349 describe_counter!(
350 "mempool.downloaded.transactions.total",
351 Unit::Count,
352 "Transactions downloaded for the mempool, by transaction version."
353 );
354 describe_counter!(
355 "mempool.pushed.transactions.total",
356 Unit::Count,
357 "Transactions submitted to the mempool directly, such as by RPC, by transaction version."
358 );
359 describe_counter!(
360 "mempool.verified.transactions.total",
361 Unit::Count,
362 "Transactions verified for the mempool, by transaction version."
363 );
364 describe_counter!(
365 "mempool.failed.verify.tasks.total",
366 Unit::Count,
367 "Mempool download and verify tasks that failed, by reason."
368 );
369 describe_counter!(
370 "mempool.cancelled.verify.tasks.total",
371 Unit::Count,
372 "Mempool download and verify tasks cancelled."
373 );
374 describe_counter!(
375 "mempool.gossiped.transactions.total",
376 Unit::Count,
377 "Mempool transaction IDs gossiped to peers."
378 );
379 describe_gauge!(
380 "mempool.rejected.transaction.ids",
381 Unit::Count,
382 "Transaction IDs in the mempool's rejected lists."
383 );
384 describe_gauge!(
385 "mempool.rejected.transaction.ids.bytes",
386 Unit::Bytes,
387 "Approximate memory used by the mempool's rejected lists."
388 );
389 describe_gauge!(
390 "zcash.mempool.size.transactions",
391 Unit::Count,
392 "Transactions in the mempool."
393 );
394 describe_gauge!(
395 "zcash.mempool.size.bytes",
396 Unit::Bytes,
397 "Serialized size of the transactions in the mempool."
398 );
399 describe_gauge!(
400 "zcash.mempool.cost.bytes",
401 Unit::Bytes,
402 "Total ZIP-401 eviction cost of the transactions in the mempool."
403 );
404 describe_gauge!(
405 "zcash.mempool.size.weighted",
406 Unit::Bytes,
407 "Serialized size of the mempool transactions in each fee weight ratio bucket."
408 );
409 describe_gauge!(
410 "zcash.mempool.actions.unpaid",
411 Unit::Count,
412 "Unpaid actions in the mempool in each fee weight ratio bucket."
413 );
414 describe_gauge!(
415 "zcash.mempool.actions.paid",
416 Unit::Count,
417 "Paid actions in the mempool."
418 );
419}