mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 02:56:18 +00:00
feat(ilm): expose lifecycle expiry scanner counters (#5262)
Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -212,6 +212,18 @@ fn record_scanner_lifecycle_enqueue_result(src: &LcEventSrc, count: u64, queued:
|
||||
}
|
||||
}
|
||||
|
||||
fn record_scanner_lifecycle_expiry_blocked(src: &LcEventSrc, count: u64) {
|
||||
if matches!(src, LcEventSrc::Scanner) {
|
||||
global_metrics().record_scanner_expiry_blocked(count);
|
||||
}
|
||||
}
|
||||
|
||||
fn record_scanner_lifecycle_expiry_delete_failed(src: &LcEventSrc, count: u64) {
|
||||
if matches!(src, LcEventSrc::Scanner) {
|
||||
global_metrics().record_scanner_expiry_delete_failed(count);
|
||||
}
|
||||
}
|
||||
|
||||
fn record_scanner_transition_enqueue_result(src: &LcEventSrc, count: u64, queued: bool) {
|
||||
if matches!(src, LcEventSrc::Scanner) {
|
||||
global_metrics().record_scanner_transition_enqueue_result(count, queued);
|
||||
@@ -845,6 +857,7 @@ impl ExpiryState {
|
||||
if deleted {
|
||||
trace.emit(EVENT_LIFECYCLE_DELETE_COMPLETED, "delete_completed", None);
|
||||
} else {
|
||||
record_scanner_lifecycle_expiry_delete_failed(&v.src, 1);
|
||||
trace.emit(
|
||||
EVENT_LIFECYCLE_DELETE_FAILED,
|
||||
"delete_failed",
|
||||
@@ -3495,6 +3508,7 @@ async fn enqueue_expiry_for_existing_object_group(
|
||||
}
|
||||
};
|
||||
if blocked_by_replication {
|
||||
record_scanner_lifecycle_expiry_blocked(context.src, 1);
|
||||
continue;
|
||||
}
|
||||
apply_existing_object_expiry(context.api.clone(), object, event, context.src).await;
|
||||
@@ -5504,6 +5518,7 @@ mod tests {
|
||||
assert_eq!(state.stats.missed_tasks(), 1);
|
||||
let after = global_metrics().report().await.lifecycle_expiry;
|
||||
assert!(after.scanner_missed >= before.scanner_missed.saturating_add(1));
|
||||
assert!(after.scanner_not_enqueued >= before.scanner_not_enqueued.saturating_add(1));
|
||||
let observed = observed.lock().expect("observability test events should not poison");
|
||||
assert!(observed.contains(&(EVENT_LIFECYCLE_EXPIRED_DETECTED, "detected", None)));
|
||||
assert!(observed.contains(&(EVENT_LIFECYCLE_NOT_ENQUEUED, "not_enqueued", Some("worker_unavailable"))));
|
||||
@@ -5607,6 +5622,8 @@ mod tests {
|
||||
assert!(!second);
|
||||
assert_eq!(state.stats.pending_tasks(), 1);
|
||||
assert_eq!(state.stats.missed_tasks(), 1);
|
||||
let after = global_metrics().report().await.lifecycle_expiry;
|
||||
assert!(after.scanner_not_enqueued >= 1);
|
||||
let observed = observed.lock().expect("observability test events should not poison");
|
||||
assert_eq!(
|
||||
observed
|
||||
|
||||
@@ -192,6 +192,9 @@ fn to_madmin_scanner_metrics(metrics: rustfs_common::metrics::ScannerMetricsRepo
|
||||
queue_missed: metrics.lifecycle_expiry.queue_missed,
|
||||
scanner_queued: metrics.lifecycle_expiry.scanner_queued,
|
||||
scanner_missed: metrics.lifecycle_expiry.scanner_missed,
|
||||
scanner_blocked: metrics.lifecycle_expiry.scanner_blocked,
|
||||
scanner_not_enqueued: metrics.lifecycle_expiry.scanner_not_enqueued,
|
||||
delete_failed: metrics.lifecycle_expiry.delete_failed,
|
||||
},
|
||||
usage_freshness: MadminScannerUsageFreshnessSnapshot {
|
||||
dirty_pending_buckets: metrics.usage_freshness.dirty_pending_buckets,
|
||||
@@ -646,6 +649,9 @@ mod test {
|
||||
queue_missed: 3,
|
||||
scanner_queued: 6,
|
||||
scanner_missed: 2,
|
||||
scanner_blocked: 4,
|
||||
scanner_not_enqueued: 2,
|
||||
delete_failed: 1,
|
||||
},
|
||||
lifecycle_transition: rustfs_common::metrics::ScannerLifecycleTransitionSnapshot {
|
||||
current_queue_capacity: 16,
|
||||
@@ -672,6 +678,9 @@ mod test {
|
||||
assert_eq!(scanner.lifecycle_expiry.queue_missed, 3);
|
||||
assert_eq!(scanner.lifecycle_expiry.scanner_queued, 6);
|
||||
assert_eq!(scanner.lifecycle_expiry.scanner_missed, 2);
|
||||
assert_eq!(scanner.lifecycle_expiry.scanner_blocked, 4);
|
||||
assert_eq!(scanner.lifecycle_expiry.scanner_not_enqueued, 2);
|
||||
assert_eq!(scanner.lifecycle_expiry.delete_failed, 1);
|
||||
assert_eq!(scanner.lifecycle_transition.current_queue_capacity, 16);
|
||||
assert_eq!(scanner.lifecycle_transition.current_queued, 5);
|
||||
assert_eq!(scanner.lifecycle_transition.current_active, 2);
|
||||
|
||||
Reference in New Issue
Block a user