refactor(logging): unify governance runtime events (#3367)

This commit is contained in:
houseme
2026-06-11 22:26:02 +08:00
committed by GitHub
parent b5676dcc8e
commit 82af181dcf
17 changed files with 1357 additions and 184 deletions
+29 -5
View File
@@ -36,6 +36,11 @@ const METRIC_NOTIFICATION_CURRENT_SEND_IN_PROGRESS: &str = "rustfs_notification_
const METRIC_NOTIFICATION_EVENTS_ERRORS_TOTAL: &str = "rustfs_notification_events_errors_total";
const METRIC_NOTIFICATION_EVENTS_SENT_TOTAL: &str = "rustfs_notification_events_sent_total";
const METRIC_NOTIFICATION_EVENTS_SKIPPED_TOTAL: &str = "rustfs_notification_events_skipped_total";
const LOG_COMPONENT_NOTIFY: &str = "notify";
const LOG_SUBSYSTEM_INTEGRATION: &str = "integration";
const EVENT_NOTIFY_SYSTEM_DROP: &str = "notify_system_drop";
const EVENT_NOTIFY_SYSTEM_SHUTDOWN_METRIC: &str = "notify_system_shutdown_metric";
const EVENT_NOTIFY_SYSTEM_STATUS_SNAPSHOT: &str = "notify_system_status_snapshot";
#[derive(Clone)]
pub struct LiveEventBatch {
@@ -362,7 +367,13 @@ impl NotificationSystem {
impl Drop for NotificationSystem {
fn drop(&mut self) {
// Asynchronous operation cannot be used here, but logs can be recorded.
info!("Notify the system instance to be destroyed");
info!(
event = EVENT_NOTIFY_SYSTEM_DROP,
component = LOG_COMPONENT_NOTIFY,
subsystem = LOG_SUBSYSTEM_INTEGRATION,
state = "dropping",
"Notification system instance is being dropped"
);
let snapshot = self.snapshot_metrics();
for (name, value, is_gauge) in [
@@ -376,15 +387,28 @@ impl Drop for NotificationSystem {
} else {
counter!(name).absolute(value);
}
info!("shutdown metric {}={}", name, value);
info!(
event = EVENT_NOTIFY_SYSTEM_SHUTDOWN_METRIC,
component = LOG_COMPONENT_NOTIFY,
subsystem = LOG_SUBSYSTEM_INTEGRATION,
metric_name = name,
metric_value = value,
metric_kind = if is_gauge { "gauge" } else { "counter" },
"Notification shutdown metric snapshot"
);
}
let status = self.get_status();
for (key, value) in status {
info!("key:{}, value:{}", key, value);
info!(
event = EVENT_NOTIFY_SYSTEM_STATUS_SNAPSHOT,
component = LOG_COMPONENT_NOTIFY,
subsystem = LOG_SUBSYSTEM_INTEGRATION,
status_key = %key,
status_value = %value,
"Notification system status snapshot"
);
}
info!("Notification system status at shutdown:");
}
}