1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
910//! Prometheus monitoring metrics.
1112use mz_ore::metric;
13use mz_ore::metrics::{IntCounter, MetricsRegistry};
14use prometheus::{Counter, IntGaugeVec};
1516#[derive(Debug, Clone)]
17pub struct Metrics {
18pub transactions_started: IntCounter,
19pub transaction_commits: IntCounter,
20pub transaction_commit_latency_seconds: Counter,
21pub snapshots_taken: IntCounter,
22pub snapshot_latency_seconds: Counter,
23pub syncs: IntCounter,
24pub sync_latency_seconds: Counter,
25pub collection_entries: IntGaugeVec,
26}
2728impl Metrics {
29/// Returns a new [Metrics] instance connected to the given registry.
30pub fn new(registry: &MetricsRegistry) -> Self {
31Self {
32 transactions_started: registry.register(metric!(
33 name: "mz_catalog_transactions_started",
34 help: "Total number of started transactions.",
35 )),
36 transaction_commits: registry.register(metric!(
37 name: "mz_catalog_transaction_commits",
38 help: "Count of transaction commits.",
39 )),
40 transaction_commit_latency_seconds: registry.register(metric!(
41 name: "mz_catalog_transaction_commit_latency_seconds",
42 help: "Total latency for committing a durable catalog transactions.",
43 )),
44 snapshots_taken: registry.register(metric!(
45 name: "mz_catalog_snapshots_taken",
46 help: "Count of snapshots taken.",
47 )),
48 snapshot_latency_seconds: registry.register(metric!(
49 name: "mz_catalog_snapshot_latency_seconds",
50 help: "Total latency for fetching a snapshot of the durable catalog.",
51 )),
52 syncs: registry.register(metric!(
53 name: "mz_catalog_syncs",
54 help: "Count of catalog syncs.",
55 )),
56 sync_latency_seconds: registry.register(metric!(
57 name: "mz_catalog_sync_latency_seconds",
58 help: "Total latency for syncing the in-memory state of the durable catalog with the persisted contents.",
59 )),
60 collection_entries: registry.register(metric!(
61 name: "mz_catalog_collection_entries",
62 help: "Total number of entries, after consolidation, per catalog collection.",
63 var_labels: ["collection"],
64 )),
65 }
66 }
67}