Skip to content

Commit a75f4fd

Browse files
emmaling27Convex, Inc.
authored andcommitted
Rename index retention metrics (#43232)
It's confusing that some retention metrics are named without specifying that they are for index retention, not document retention. GitOrigin-RevId: f506c4ced78e84a5445abb56e1d6546b5052a5b1
1 parent f81123e commit a75f4fd

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

crates/database/src/metrics.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ pub fn retention_advance_timestamp_timer() -> Timer<VMHistogram> {
447447
}
448448

449449
register_convex_histogram!(
450-
RETENTION_DELETE_SECONDS,
451-
"Time for retention to complete deletions"
450+
INDEX_RETENTION_DELETE_SECONDS,
451+
"Time for index retention to complete deletions"
452452
);
453-
pub fn retention_delete_timer() -> Timer<VMHistogram> {
454-
Timer::new(&RETENTION_DELETE_SECONDS)
453+
pub fn index_retention_delete_timer() -> Timer<VMHistogram> {
454+
Timer::new(&INDEX_RETENTION_DELETE_SECONDS)
455455
}
456456

457457
register_convex_histogram!(
@@ -463,11 +463,11 @@ pub fn retention_delete_documents_timer() -> Timer<VMHistogram> {
463463
}
464464

465465
register_convex_histogram!(
466-
RETENTION_DELETE_CHUNK_SECONDS,
467-
"Time for retention to delete one chunk"
466+
INDEX_RETENTION_DELETE_CHUNK_SECONDS,
467+
"Time for index retention to delete one chunk"
468468
);
469-
pub fn retention_delete_chunk_timer() -> Timer<VMHistogram> {
470-
Timer::new(&RETENTION_DELETE_CHUNK_SECONDS)
469+
pub fn index_retention_delete_chunk_timer() -> Timer<VMHistogram> {
470+
Timer::new(&INDEX_RETENTION_DELETE_CHUNK_SECONDS)
471471
}
472472

473473
register_convex_histogram!(
@@ -478,17 +478,20 @@ pub fn retention_delete_document_chunk_timer() -> Timer<VMHistogram> {
478478
Timer::new(&RETENTION_DELETE_DOCUMENT_CHUNK_SECONDS)
479479
}
480480

481-
register_convex_histogram!(RETENTION_CURSOR_AGE_SECONDS, "Age of the retention cursor");
482-
pub fn log_retention_cursor_age(age_secs: f64) {
483-
log_distribution(&RETENTION_CURSOR_AGE_SECONDS, age_secs)
481+
register_convex_histogram!(
482+
INDEX_RETENTION_CURSOR_AGE_SECONDS,
483+
"Age of the index retention cursor"
484+
);
485+
pub fn log_index_retention_cursor_age(age_secs: f64) {
486+
log_distribution(&INDEX_RETENTION_CURSOR_AGE_SECONDS, age_secs)
484487
}
485488

486489
register_convex_histogram!(
487-
RETENTION_CURSOR_LAG_SECONDS,
488-
"Lag between the retention cursor and the min index snapshot"
490+
INDEX_RETENTION_CURSOR_LAG_SECONDS,
491+
"Lag between the index retention cursor and the min index snapshot"
489492
);
490-
pub fn log_retention_cursor_lag(age_secs: f64) {
491-
log_distribution(&RETENTION_CURSOR_LAG_SECONDS, age_secs)
493+
pub fn log_index_retention_cursor_lag(age_secs: f64) {
494+
log_distribution(&INDEX_RETENTION_CURSOR_LAG_SECONDS, age_secs)
492495
}
493496

494497
register_convex_histogram!(
@@ -508,11 +511,11 @@ pub fn log_document_retention_cursor_lag(age_secs: f64) {
508511
}
509512

510513
register_convex_counter!(
511-
RETENTION_MISSING_CURSOR_INFO,
514+
INDEX_RETENTION_MISSING_CURSOR_INFO,
512515
"Index retention has no cursor"
513516
);
514-
pub fn log_retention_no_cursor() {
515-
log_counter(&RETENTION_MISSING_CURSOR_INFO, 1)
517+
pub fn log_index_retention_no_cursor() {
518+
log_counter(&INDEX_RETENTION_MISSING_CURSOR_INFO, 1)
516519
}
517520

518521
register_convex_counter!(
@@ -524,13 +527,13 @@ pub fn log_document_retention_no_cursor() {
524527
}
525528

526529
register_convex_counter!(
527-
RETENTION_SCANNED_DOCUMENT_TOTAL,
528-
"Count of documents scanned by retention",
530+
INDEX_RETENTION_SCANNED_DOCUMENT_TOTAL,
531+
"Count of documents scanned by index retention",
529532
&["tombstone", "prev_rev"]
530533
);
531-
pub fn log_retention_scanned_document(is_tombstone: bool, has_prev_rev: bool) {
534+
pub fn log_index_retention_scanned_document(is_tombstone: bool, has_prev_rev: bool) {
532535
log_counter_with_labels(
533-
&RETENTION_SCANNED_DOCUMENT_TOTAL,
536+
&INDEX_RETENTION_SCANNED_DOCUMENT_TOTAL,
534537
1,
535538
vec![
536539
StaticMetricLabel::new(

crates/database/src/retention.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,26 @@ use value::InternalDocumentId;
132132

133133
use crate::{
134134
metrics::{
135+
index_retention_delete_chunk_timer,
136+
index_retention_delete_timer,
135137
latest_min_document_snapshot_timer,
136138
latest_min_snapshot_timer,
137139
log_document_retention_cursor_age,
138140
log_document_retention_cursor_lag,
139141
log_document_retention_no_cursor,
140142
log_document_retention_scanned_document,
141-
log_retention_cursor_age,
142-
log_retention_cursor_lag,
143+
log_index_retention_cursor_age,
144+
log_index_retention_cursor_lag,
145+
log_index_retention_no_cursor,
146+
log_index_retention_scanned_document,
143147
log_retention_documents_deleted,
144148
log_retention_expired_index_entry,
145149
log_retention_index_entries_deleted,
146-
log_retention_no_cursor,
147-
log_retention_scanned_document,
148150
log_retention_ts_advanced,
149151
log_snapshot_verification_age,
150152
retention_advance_timestamp_timer,
151-
retention_delete_chunk_timer,
152153
retention_delete_document_chunk_timer,
153154
retention_delete_documents_timer,
154-
retention_delete_timer,
155155
},
156156
snapshot_manager::SnapshotManager,
157157
BootstrapMetadata,
@@ -579,7 +579,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
579579
// If this happens for a tombstone, it means the document was created and
580580
// deleted in the same transaction, with no index rows.
581581
let Some(prev_rev) = prev_rev else {
582-
log_retention_scanned_document(maybe_doc.is_none(), false);
582+
log_index_retention_scanned_document(maybe_doc.is_none(), false);
583583
continue;
584584
};
585585
let DocumentRevision {
@@ -594,10 +594,10 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
594594
prev_ts = prev_rev.ts
595595
);
596596
report_error(&mut e).await;
597-
log_retention_scanned_document(maybe_doc.is_none(), false);
597+
log_index_retention_scanned_document(maybe_doc.is_none(), false);
598598
continue;
599599
};
600-
log_retention_scanned_document(maybe_doc.is_none(), true);
600+
log_index_retention_scanned_document(maybe_doc.is_none(), true);
601601
for (index_id, (_, index_fields)) in all_indexes
602602
.iter()
603603
.filter(|(_, (index, _))| *index.table() == id.table())
@@ -967,7 +967,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
967967
persistence: Arc<dyn Persistence>,
968968
mut new_cursor: Timestamp,
969969
) -> anyhow::Result<(Timestamp, usize)> {
970-
let _timer = retention_delete_chunk_timer();
970+
let _timer = index_retention_delete_chunk_timer();
971971
let index_entries_to_delete = delete_chunk.len();
972972
tracing::trace!("delete: got entries to delete {index_entries_to_delete:?}");
973973
for index_entry_to_delete in delete_chunk.iter() {
@@ -1087,7 +1087,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
10871087
);
10881088
let span = get_sampled_span("", "delete_indexes", &mut rt.rng());
10891089
let r: anyhow::Result<()> = async {
1090-
let _timer = retention_delete_timer();
1090+
let _timer = index_retention_delete_timer();
10911091
let cursor = Self::get_checkpoint(
10921092
reader.as_ref(),
10931093
snapshot_reader.clone(),
@@ -1307,11 +1307,11 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
13071307
);
13081308
},
13091309
RetentionType::Index => {
1310-
log_retention_cursor_age(
1310+
log_index_retention_cursor_age(
13111311
(*snapshot_reader.lock().persisted_max_repeatable_ts())
13121312
.secs_since_f64(*cursor),
13131313
);
1314-
log_retention_cursor_lag(
1314+
log_index_retention_cursor_lag(
13151315
bounds_reader
13161316
.lock()
13171317
.min_index_snapshot_ts
@@ -1322,7 +1322,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
13221322
} else {
13231323
match retention_type {
13241324
RetentionType::Document => log_document_retention_no_cursor(),
1325-
RetentionType::Index => log_retention_no_cursor(),
1325+
RetentionType::Index => log_index_retention_no_cursor(),
13261326
}
13271327
}
13281328
Ok(())

0 commit comments

Comments
 (0)