Skip to content

Commit 1be6a6f

Browse files
committed
adapter: add histogram metrics for apply_catalog_implications
This adds a new HistogramVec metric 'mz_apply_catalog_implications_seconds' to track the duration of apply_catalog_implications methods. The metric includes a 'method' label to distinguish between: - apply_catalog_implications - apply_catalog_implications_inner
1 parent b05b343 commit 1be6a6f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/adapter/src/coord/catalog_implications.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
2929
use std::collections::{BTreeMap, BTreeSet};
3030
use std::sync::Arc;
31-
use std::time::Duration;
31+
use std::time::{Duration, Instant};
3232

3333
use fail::fail_point;
3434
use itertools::Itertools;
@@ -82,6 +82,8 @@ impl Coordinator {
8282
ctx: Option<&mut ExecuteContext>,
8383
catalog_updates: Vec<ParsedStateUpdate>,
8484
) -> Result<(), AdapterError> {
85+
let start = Instant::now();
86+
8587
let mut catalog_implications: BTreeMap<CatalogItemId, CatalogImplication> = BTreeMap::new();
8688
let mut cluster_commands: BTreeMap<ClusterId, CatalogImplication> = BTreeMap::new();
8789
let mut cluster_replica_commands: BTreeMap<(ClusterId, ReplicaId), CatalogImplication> =
@@ -144,6 +146,10 @@ impl Coordinator {
144146
)
145147
.await?;
146148

149+
self.metrics
150+
.apply_catalog_implications_seconds
151+
.observe(start.elapsed().as_secs_f64());
152+
147153
Ok(())
148154
}
149155

src/adapter/src/metrics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct Metrics {
5151
pub catalog_snapshot_seconds: HistogramVec,
5252
pub pgwire_recv_scheduling_delay_ms: HistogramVec,
5353
pub catalog_transact_seconds: HistogramVec,
54+
pub apply_catalog_implications_seconds: Histogram,
5455
}
5556

5657
impl Metrics {
@@ -228,6 +229,11 @@ impl Metrics {
228229
help: "The time it takes to run various catalog transact methods.",
229230
var_labels: ["method"],
230231
buckets: histogram_seconds_buckets(0.001, 32.0),
232+
)),
233+
apply_catalog_implications_seconds: registry.register(metric!(
234+
name: "mz_apply_catalog_implications_seconds",
235+
help: "The time it takes to apply catalog implications.",
236+
buckets: histogram_seconds_buckets(0.001, 32.0),
231237
))
232238
}
233239
}

0 commit comments

Comments
 (0)