use mz_ore::metric;
use mz_ore::metrics::{IntCounter, MetricsRegistry};
use prometheus::{Counter, IntGaugeVec};
#[derive(Debug, Clone)]
pub struct Metrics {
pub transactions_started: IntCounter,
pub transaction_commits: IntCounter,
pub transaction_commit_latency_seconds: Counter,
pub snapshots_taken: IntCounter,
pub snapshot_latency_seconds: Counter,
pub syncs: IntCounter,
pub sync_latency_seconds: Counter,
pub collection_entries: IntGaugeVec,
}
impl Metrics {
pub fn new(registry: &MetricsRegistry) -> Self {
Self {
transactions_started: registry.register(metric!(
name: "mz_catalog_transactions_started",
help: "Total number of started transactions.",
)),
transaction_commits: registry.register(metric!(
name: "mz_catalog_transaction_commits",
help: "Count of transaction commits.",
)),
transaction_commit_latency_seconds: registry.register(metric!(
name: "mz_catalog_transaction_commit_latency_seconds",
help: "Total latency for committing a durable catalog transactions.",
)),
snapshots_taken: registry.register(metric!(
name: "mz_catalog_snapshots_taken",
help: "Count of snapshots taken.",
)),
snapshot_latency_seconds: registry.register(metric!(
name: "mz_catalog_snapshot_latency_seconds",
help: "Total latency for fetching a snapshot of the durable catalog.",
)),
syncs: registry.register(metric!(
name: "mz_catalog_syncs",
help: "Count of catalog syncs.",
)),
sync_latency_seconds: registry.register(metric!(
name: "mz_catalog_sync_latency_seconds",
help: "Total latency for syncing the in-memory state of the durable catalog with the persisted contents.",
)),
collection_entries: registry.register(metric!(
name: "mz_catalog_collection_entries",
help: "Total number of entries, after consolidation, per catalog collection.",
var_labels: ["collection"],
)),
}
}
}