Skip to content

Commit 901eb7e

Browse files
committed
Move PKs and Clock count from light metrics to heavy metrics
1 parent f0c69ea commit 901eb7e

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

crates/corro-agent/src/agent/metrics.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,6 @@ pub fn collect_light_metrics(agent: &Agent, transport: &Transport) {
6161
continue;
6262
}
6363
}
64-
match conn
65-
.prepare_cached(&format!("SELECT count(*) FROM {table}__crsql_pks"))
66-
.and_then(|mut prepped| prepped.query_row([], |row| row.get::<_, i64>(0)))
67-
{
68-
Ok(count) => {
69-
gauge!("corro.db.table.bookkeeping.pks.rows.total", "table" => table.clone())
70-
.set(count as f64);
71-
}
72-
Err(e) => {
73-
error!("could not query __crsql_pks count for table {table}: {e}");
74-
continue;
75-
}
76-
}
77-
match conn
78-
.prepare_cached(&format!("SELECT count(*) FROM {table}__crsql_clock"))
79-
.and_then(|mut prepped| prepped.query_row([], |row| row.get::<_, i64>(0)))
80-
{
81-
Ok(count) => {
82-
gauge!("corro.db.table.bookkeeping.clock.rows.total", "table" => table.clone())
83-
.set(count as f64);
84-
}
85-
Err(e) => {
86-
error!("could not query __crsql_clock count for table {table}: {e}");
87-
continue;
88-
}
89-
}
9064
}
9165

9266
// TODO: collect from bookie?
@@ -191,5 +165,33 @@ pub fn collect_heavy_metrics(agent: &Agent) {
191165
.set(real_usage as f64);
192166
persistent_gauge!("corro.db.table.bookkeeping.btree.bytes", "table" => table.clone())
193167
.set(bookkeeping_usage as f64);
168+
169+
// Pks and Clock counts
170+
match conn
171+
.prepare_cached(&format!("SELECT count(*) FROM {table}__crsql_pks"))
172+
.and_then(|mut prepped| prepped.query_row([], |row| row.get::<_, i64>(0)))
173+
{
174+
Ok(count) => {
175+
persistent_gauge!("corro.db.table.bookkeeping.pks.rows.total", "table" => table.clone())
176+
.set(count as f64);
177+
}
178+
Err(e) => {
179+
error!("could not query __crsql_pks count for table {table}: {e}");
180+
continue;
181+
}
182+
}
183+
match conn
184+
.prepare_cached(&format!("SELECT count(*) FROM {table}__crsql_clock"))
185+
.and_then(|mut prepped| prepped.query_row([], |row| row.get::<_, i64>(0)))
186+
{
187+
Ok(count) => {
188+
persistent_gauge!("corro.db.table.bookkeeping.clock.rows.total", "table" => table.clone())
189+
.set(count as f64);
190+
}
191+
Err(e) => {
192+
error!("could not query __crsql_clock count for table {table}: {e}");
193+
continue;
194+
}
195+
}
194196
}
195197
}

0 commit comments

Comments
 (0)