use metrics::{describe_counter, describe_gauge, describe_histogram, Unit};
pub const LABELS: &[(&str, &[&str])] = &[
("zebrad.build.info", &["version", "commit"]),
("sync.restart.count", &["reason", "made_progress"]),
("sync.block.error.count", &["kind"]),
("sync.block.download.duration_seconds", &["result"]),
("sync.block.verify.duration_seconds", &["result"]),
("sync.stage.duration_seconds", &["stage"]),
("mempool.failed.verify.tasks.total", &["reason"]),
("mempool.downloaded.transactions.total", &["version"]),
("mempool.pushed.transactions.total", &["version"]),
("mempool.verified.transactions.total", &["version"]),
("zcash.mempool.actions.unpaid", &["bk"]),
("zcash.mempool.size.weighted", &["bk"]),
(
"zcash.chain.tip.block_delay_seconds",
&["chain.network_upgrade"],
),
("zebrad.sentry.metrics.dropped.total", &["reason"]),
("sync.mined.block.announcement.outcomes.total", &["outcome"]),
];
pub fn describe() {
describe_counter!(
concat!(env!("CARGO_PKG_NAME"), ".build.info"),
Unit::Count,
"Always 1, with the running zebrad version and git commit as labels."
);
describe_counter!(
"zebrad.sentry.metrics.dropped.total",
Unit::Count,
"Metric values that weren't sent to Sentry when due, because a flush was full, the Sentry \
transport was still sending earlier data, or the metric had too many label sets."
);
describe_gauge!(
"process.memory.rss_bytes",
Unit::Bytes,
"Memory zebrad is using, its resident set size. Only recorded on Linux."
);
describe_gauge!(
"process.memory.rss_fraction",
Unit::Count,
"process.memory.rss_bytes as a fraction of the memory zebrad can use: the tightest \
cgroup memory limit, or the machine's memory if that is smaller."
);
describe_sync();
describe_gossip();
describe_mempool();
describe_gauge!(
"zcashd.compat.supervisor.active",
Unit::Count,
"1 while zebrad is supervising a zcashd child process, otherwise 0."
);
describe_gauge!(
"zcashd.compat.supervisor.disabled",
Unit::Count,
"1 when zcashd supervision is turned off or has stopped, otherwise 0."
);
describe_gauge!(
"zcashd.compat.supervisor.exhausted",
Unit::Count,
"1 when zcashd supervision stopped after too many restarts, otherwise 0."
);
}
fn describe_sync() {
describe_histogram!(
"sync.mined.block.announcement.duration_seconds",
Unit::Seconds,
"Time from a mined block's acceptance until its announcement to peers finished."
);
describe_counter!(
"sync.mined.block.announcement.outcomes.total",
Unit::Count,
"Announcements of mined blocks to peers, by whether they finished or failed."
);
describe_counter!(
"sync.restart.count",
Unit::Count,
"Sync rounds that ended, by why they ended and whether the state tip advanced."
);
describe_counter!(
"sync.block.error.count",
Unit::Count,
"Block download and verify errors, by kind."
);
describe_histogram!(
"sync.stage.duration_seconds",
Unit::Seconds,
"Time taken by each stage of a sync round."
);
describe_histogram!(
"sync.obtain.response.hash.count",
Unit::Count,
"Block hashes in each peer response while obtaining tips."
);
describe_gauge!(
"sync.obtain.queued.hash.count",
Unit::Count,
"Block hashes queued for download after obtaining tips."
);
describe_histogram!(
"sync.extend.response.hash.count",
Unit::Count,
"Block hashes in each peer response while extending tips."
);
describe_gauge!(
"sync.extend.queued.hash.count",
Unit::Count,
"Block hashes queued for download after extending tips."
);
describe_gauge!(
"sync.prospective_tips.len",
Unit::Count,
"Chain tips the syncer is following."
);
describe_gauge!(
"sync.downloads.in_flight",
Unit::Count,
"Blocks the syncer is downloading or verifying."
);
describe_gauge!(
"sync.downloads.oldest_age_seconds",
Unit::Seconds,
"How long the oldest block still being downloaded or verified has waited, or 0 when none are."
);
describe_gauge!(
"sync.estimated_network_tip_height",
Unit::Count,
"Estimated height of the network's chain tip."
);
describe_gauge!(
"sync.estimated_distance_to_tip",
Unit::Count,
"Estimated number of blocks between the state tip and the network's chain tip."
);
describe_histogram!(
"zcash.chain.tip.block_delay_seconds",
Unit::Seconds,
"Time from a block's header time until it became this node's best chain tip."
);
describe_histogram!(
"sync.block.download.duration_seconds",
Unit::Seconds,
"Time taken to download a block during sync."
);
describe_histogram!(
"sync.block.verify.duration_seconds",
Unit::Seconds,
"Time taken to verify a downloaded block during sync."
);
describe_counter!(
"sync.downloaded.block.count",
Unit::Count,
"Blocks downloaded by the syncer."
);
describe_counter!(
"sync.verified.block.count",
Unit::Count,
"Blocks verified after the syncer downloaded them."
);
describe_counter!(
"sync.already.queued.dropped.block.hash.count",
Unit::Count,
"Block hashes the syncer ignored because they were already queued for download."
);
describe_counter!(
"sync.already.rejected.dropped.block.hash.count",
Unit::Count,
"Block hashes the syncer ignored because a compact relay peer already sent that block, \
and it failed validation after its early relay checks."
);
describe_counter!(
"sync.no.height.dropped.block.count",
Unit::Count,
"Downloaded blocks dropped because they have no coinbase height."
);
describe_counter!(
"sync.cancelled.download.count",
Unit::Count,
"Block downloads cancelled by a sync restart."
);
describe_counter!(
"sync.cancelled.verify.ready.count",
Unit::Count,
"Block verifications cancelled while waiting for the verifier to be ready."
);
describe_counter!(
"sync.cancelled.verify.count",
Unit::Count,
"Block verifications cancelled by a sync restart."
);
describe_counter!(
"sync.max.height.limit.paused.count",
Unit::Count,
"Times downloads paused because the syncer got too far ahead of the state tip."
);
describe_counter!(
"sync.max.height.limit.reset.count",
Unit::Count,
"Times downloads resumed after the state tip caught up with the syncer."
);
describe_counter!(
"sync.max.height.limit.reset.attempt.count",
Unit::Count,
"Attempts to resume downloads after the state tip caught up with the syncer."
);
}
fn describe_gossip() {
describe_histogram!(
"gossip.block.download.duration_seconds",
Unit::Seconds,
"Time taken to download a gossiped block, from the request to a successful response."
);
describe_histogram!(
"gossip.block.verify_commit.duration_seconds",
Unit::Seconds,
"Time from sending a downloaded gossiped block to the block verifier until it was \
committed."
);
describe_gauge!(
"gossip.queued.block.count",
Unit::Count,
"Gossiped blocks queued for download and verification."
);
describe_counter!(
"gossip.already.queued.dropped.block.hash.count",
Unit::Count,
"Gossiped block hashes ignored because they were already queued."
);
describe_counter!(
"gossip.already.rejected.dropped.block.hash.count",
Unit::Count,
"Gossiped block hashes ignored because a compact relay peer already sent that block, \
and it failed validation after its early relay checks."
);
describe_counter!(
"gossip.full.queue.dropped.block.hash.count",
Unit::Count,
"Gossiped block hashes ignored because the download queue was full."
);
describe_counter!(
"gossip.peer.limit.dropped.block.hash.count",
Unit::Count,
"Gossiped block hashes ignored because the peer already had a download in progress."
);
describe_counter!(
"gossip.downloaded.block.count",
Unit::Count,
"Gossiped blocks downloaded."
);
describe_counter!(
"gossip.verified.block.count",
Unit::Count,
"Gossiped blocks verified."
);
describe_counter!(
"gossip.cancelled.count",
Unit::Count,
"Gossiped block downloads or verifications cancelled."
);
describe_counter!(
"gossip.no.height.dropped.block.count",
Unit::Count,
"Gossiped blocks dropped because they have no coinbase height."
);
describe_counter!(
"gossip.max.height.limit.dropped.block.count",
Unit::Count,
"Gossiped blocks dropped because they are too far above the state tip."
);
describe_counter!(
"gossip.min.height.limit.dropped.block.count",
Unit::Count,
"Downloaded blocks dropped because they are behind the finalized tip."
);
}
fn describe_mempool() {
describe_histogram!(
"mempool.tip_cleanup.duration_seconds",
Unit::Seconds,
"Time taken to remove a new tip block's transactions and their conflicts from the mempool."
);
describe_histogram!(
"mempool.expiry.duration_seconds",
Unit::Seconds,
"Time taken by each check of the mempool for expired transactions."
);
describe_gauge!(
"mempool.currently.queued.transactions",
Unit::Count,
"Transactions queued for mempool download and verification."
);
describe_counter!(
"mempool.queued.transactions.total",
Unit::Count,
"Transactions queued for mempool download and verification."
);
describe_counter!(
"mempool.full_queue.per_peer.total",
Unit::Count,
"Transactions ignored because their peer already had too many queued."
);
describe_counter!(
"mempool.downloaded.transactions.total",
Unit::Count,
"Transactions downloaded for the mempool, by transaction version."
);
describe_counter!(
"mempool.pushed.transactions.total",
Unit::Count,
"Transactions submitted to the mempool directly, such as by RPC, by transaction version."
);
describe_counter!(
"mempool.verified.transactions.total",
Unit::Count,
"Transactions verified for the mempool, by transaction version."
);
describe_counter!(
"mempool.failed.verify.tasks.total",
Unit::Count,
"Mempool download and verify tasks that failed, by reason."
);
describe_counter!(
"mempool.cancelled.verify.tasks.total",
Unit::Count,
"Mempool download and verify tasks cancelled."
);
describe_counter!(
"mempool.gossiped.transactions.total",
Unit::Count,
"Mempool transaction IDs gossiped to peers."
);
describe_gauge!(
"mempool.rejected.transaction.ids",
Unit::Count,
"Transaction IDs in the mempool's rejected lists."
);
describe_gauge!(
"mempool.rejected.transaction.ids.bytes",
Unit::Bytes,
"Approximate memory used by the mempool's rejected lists."
);
describe_gauge!(
"zcash.mempool.size.transactions",
Unit::Count,
"Transactions in the mempool."
);
describe_gauge!(
"zcash.mempool.size.bytes",
Unit::Bytes,
"Serialized size of the transactions in the mempool."
);
describe_gauge!(
"zcash.mempool.cost.bytes",
Unit::Bytes,
"Total ZIP-401 eviction cost of the transactions in the mempool."
);
describe_gauge!(
"zcash.mempool.size.weighted",
Unit::Bytes,
"Serialized size of the mempool transactions in each fee weight ratio bucket."
);
describe_gauge!(
"zcash.mempool.actions.unpaid",
Unit::Count,
"Unpaid actions in the mempool in each fee weight ratio bucket."
);
describe_gauge!(
"zcash.mempool.actions.paid",
Unit::Count,
"Paid actions in the mempool."
);
}