mz_catalog/durable/
metrics.rs1use mz_ore::metric;
13use mz_ore::metrics::{IntCounter, MetricsRegistry};
14use mz_ore::stats::histogram_seconds_buckets;
15use prometheus::{Counter, Histogram, IntGauge, IntGaugeVec};
16
17#[derive(Debug, Clone)]
18pub struct Metrics {
19 pub transactions_started: IntCounter,
20 pub transaction_commits: IntCounter,
21 pub transaction_commit_latency_seconds: Counter,
22 pub snapshots_taken: IntCounter,
23 pub snapshot_latency_seconds: Counter,
24 pub syncs: IntCounter,
25 pub sync_latency_seconds: Counter,
26 pub collection_entries: IntGaugeVec,
27 pub allocate_id_seconds: Histogram,
28 pub snapshot_consolidations: IntCounter,
29 pub snapshot_max_entries: IntGauge,
30}
31
32impl Metrics {
33 pub fn new(registry: &MetricsRegistry) -> Self {
35 Self {
36 transactions_started: registry.register(metric!(
37 name: "mz_catalog_transactions_started",
38 help: "Total number of started transactions.",
39 )),
40 transaction_commits: registry.register(metric!(
41 name: "mz_catalog_transaction_commits",
42 help: "Count of transaction commits.",
43 )),
44 transaction_commit_latency_seconds: registry.register(metric!(
45 name: "mz_catalog_transaction_commit_latency_seconds",
46 help: "Total latency for committing a durable catalog transactions.",
47 )),
48 snapshots_taken: registry.register(metric!(
49 name: "mz_catalog_snapshots_taken",
50 help: "Count of snapshots taken.",
51 )),
52 snapshot_latency_seconds: registry.register(metric!(
53 name: "mz_catalog_snapshot_latency_seconds",
54 help: "Total latency for fetching a snapshot of the durable catalog.",
55 )),
56 syncs: registry.register(metric!(
57 name: "mz_catalog_syncs",
58 help: "Count of catalog syncs.",
59 )),
60 sync_latency_seconds: registry.register(metric!(
61 name: "mz_catalog_sync_latency_seconds",
62 help: "Total latency for syncing the in-memory state of the durable catalog with the persisted contents.",
63 )),
64 collection_entries: registry.register(metric!(
65 name: "mz_catalog_collection_entries",
66 help: "Total number of entries, after consolidation, per catalog collection.",
67 var_labels: ["collection"],
68 )),
69 allocate_id_seconds: registry.register(metric!(
70 name: "mz_catalog_allocate_id_seconds",
71 help: "The time it takes to allocate IDs in the durable catalog.",
72 buckets: histogram_seconds_buckets(0.001, 32.0),
73 )),
74 snapshot_consolidations: registry.register(metric!(
75 name: "mz_catalog_snapshot_consolidations",
76 help: "Count of snapshot consolidation passes.",
77 )),
78 snapshot_max_entries: registry.register(metric!(
79 name: "mz_catalog_snapshot_max_entries",
80 help: "High-water mark of entries in the unconsolidated in-memory \
81 snapshot since process start.",
82 )),
83 }
84 }
85}