mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-25 13:36:50 +00:00
refactor(logging): normalize admin telemetry and error messages (#3430)
This commit is contained in:
@@ -69,7 +69,7 @@ impl NotifyBucketConfigManager {
|
||||
bucket = %bucket,
|
||||
region = %cfg.region,
|
||||
available_arn_count = arn_list.len(),
|
||||
"Loaded available notify target ARNs for bucket config validation"
|
||||
"notify bucket config validation"
|
||||
);
|
||||
|
||||
if let Err(e) = cfg.validate(&cfg.region, &arn_list) {
|
||||
@@ -81,7 +81,7 @@ impl NotifyBucketConfigManager {
|
||||
region = %cfg.region,
|
||||
error = %e,
|
||||
result = "validation_failed",
|
||||
"Bucket notification config validation failed"
|
||||
"notify bucket config validation"
|
||||
);
|
||||
if !matches!(e, ParseConfigError::ArnNotFound(_)) {
|
||||
return Err(NotificationError::BucketNotification(e.to_string()));
|
||||
@@ -94,7 +94,7 @@ impl NotifyBucketConfigManager {
|
||||
region = %cfg.region,
|
||||
error = %e,
|
||||
result = "missing_target_arn",
|
||||
"Bucket notification config references missing target ARN; keeping compatibility and loading remaining rules"
|
||||
"notify bucket config validation"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ impl NotifyBucketConfigManager {
|
||||
bucket = %bucket,
|
||||
region = %cfg.region,
|
||||
rule_count = cfg.get_rules_map().inner().len(),
|
||||
"Loaded bucket notification config"
|
||||
"notify bucket config state"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ impl NotifyConfigManager {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "initializing",
|
||||
"Initializing notification system"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
|
||||
let config = {
|
||||
@@ -111,7 +111,7 @@ impl NotifyConfigManager {
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "targets_created",
|
||||
target_count = targets.len(),
|
||||
"Created notification targets"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
if targets.is_empty() {
|
||||
debug!(
|
||||
@@ -121,7 +121,7 @@ impl NotifyConfigManager {
|
||||
state = "idle",
|
||||
reason = "no_targets_configured",
|
||||
hint = %notify_configuration_hint(),
|
||||
"Notification runtime has no configured targets"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ impl NotifyConfigManager {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "initialized",
|
||||
"Initialized notification system"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -156,13 +156,13 @@ impl NotifyConfigManager {
|
||||
if let Some(targets_of_type) = config.0.get_mut(&ttype) {
|
||||
if targets_of_type.remove(&tname).is_some() {
|
||||
info!(
|
||||
event = EVENT_NOTIFY_CONFIG_UPDATE,
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
event = EVENT_NOTIFY_CONFIG_UPDATE,
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
action = "remove_target",
|
||||
target_id = %target_id,
|
||||
result = "removed",
|
||||
"Removed notification target from configuration"
|
||||
"notify config update"
|
||||
);
|
||||
changed = true;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ impl NotifyConfigManager {
|
||||
action = "remove_target",
|
||||
target_id = %target_id,
|
||||
result = "not_found",
|
||||
"Notification target not found in configuration"
|
||||
"notify config update"
|
||||
);
|
||||
}
|
||||
changed
|
||||
@@ -246,7 +246,7 @@ impl NotifyConfigManager {
|
||||
target_type = %target_type,
|
||||
target_name = %target_name,
|
||||
result = "not_found",
|
||||
"Notification target configuration not found"
|
||||
"notify config update"
|
||||
);
|
||||
}
|
||||
debug!(
|
||||
@@ -264,7 +264,7 @@ impl NotifyConfigManager {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "reloading",
|
||||
"Reloading notification configuration"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
|
||||
self.update_config(new_config.clone()).await;
|
||||
@@ -281,7 +281,7 @@ impl NotifyConfigManager {
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "targets_created",
|
||||
target_count = targets.len(),
|
||||
"Created notification targets from reloaded configuration"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
if targets.is_empty() {
|
||||
debug!(
|
||||
@@ -291,7 +291,7 @@ impl NotifyConfigManager {
|
||||
state = "idle",
|
||||
reason = "no_targets_configured",
|
||||
hint = %notify_configuration_hint(),
|
||||
"Notification runtime has no configured targets after reload"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ impl NotifyConfigManager {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
state = "reloaded",
|
||||
"Reloaded notification configuration"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -333,7 +333,7 @@ impl NotifyConfigManager {
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
action = "reload_if_changed",
|
||||
result = "unchanged",
|
||||
"Notification configuration unchanged; skipping reload"
|
||||
"notify config update"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
@@ -348,7 +348,7 @@ impl NotifyConfigManager {
|
||||
subsystem = LOG_SUBSYSTEM_CONFIG,
|
||||
action = "reload_if_changed",
|
||||
result = "updated",
|
||||
"Notification configuration updated; reloading runtime"
|
||||
"notify config update"
|
||||
);
|
||||
self.reload_config(new_config).await
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ use std::sync::{Arc, OnceLock};
|
||||
use tracing::error;
|
||||
|
||||
static NOTIFICATION_SYSTEM: OnceLock<Arc<NotificationSystem>> = OnceLock::new();
|
||||
const LOG_COMPONENT_NOTIFY: &str = "notify";
|
||||
const LOG_SUBSYSTEM_GLOBAL: &str = "global";
|
||||
const EVENT_NOTIFY_GLOBAL_STATE: &str = "notify_global_state";
|
||||
|
||||
/// Initialize the global notification system with the given configuration.
|
||||
/// This function should only be called once throughout the application life cycle.
|
||||
@@ -102,7 +105,13 @@ pub mod notifier_global {
|
||||
// If the notification system itself cannot be retrieved, it will be returned directly
|
||||
Some(sys) => sys,
|
||||
None => {
|
||||
error!("Notification system is not initialized.");
|
||||
error!(
|
||||
event = EVENT_NOTIFY_GLOBAL_STATE,
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_GLOBAL,
|
||||
state = "uninitialized",
|
||||
"notify global state"
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -372,7 +372,7 @@ impl Drop for NotificationSystem {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_INTEGRATION,
|
||||
state = "dropping",
|
||||
"Notification system instance is being dropped"
|
||||
"notify system integration state"
|
||||
);
|
||||
|
||||
let snapshot = self.snapshot_metrics();
|
||||
@@ -394,7 +394,7 @@ impl Drop for NotificationSystem {
|
||||
metric_name = name,
|
||||
metric_value = value,
|
||||
metric_kind = if is_gauge { "gauge" } else { "counter" },
|
||||
"Notification shutdown metric snapshot"
|
||||
"notify system integration state"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ impl Drop for NotificationSystem {
|
||||
subsystem = LOG_SUBSYSTEM_INTEGRATION,
|
||||
status_key = %key,
|
||||
status_value = %value,
|
||||
"Notification system status snapshot"
|
||||
"notify system integration state"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ impl EventNotifier {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_DISPATCH,
|
||||
state = "targets_cleared",
|
||||
"Removed all notify targets"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ impl EventNotifier {
|
||||
bucket = %bucket_name,
|
||||
object = %object_key,
|
||||
target_count = target_ids_len,
|
||||
"Dispatching notify event"
|
||||
"notify dispatch"
|
||||
);
|
||||
for target_id in target_ids {
|
||||
// `get` now returns Option<Arc<dyn Target + Send + Sync>>
|
||||
@@ -166,7 +166,7 @@ impl EventNotifier {
|
||||
subsystem = LOG_SUBSYSTEM_DISPATCH,
|
||||
target_id = %target_for_task.id(),
|
||||
deferred = is_deferred,
|
||||
"Prepared notify target dispatch"
|
||||
"notify dispatch"
|
||||
);
|
||||
// Use cloned data in closures to avoid borrowing conflicts
|
||||
// Create an EntityTarget from the event
|
||||
@@ -217,7 +217,7 @@ impl EventNotifier {
|
||||
subsystem = LOG_SUBSYSTEM_DISPATCH,
|
||||
target_id = %target_name_for_task,
|
||||
deferred = is_deferred,
|
||||
"Completed notify target dispatch"
|
||||
"notify dispatch"
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -256,7 +256,7 @@ impl EventNotifier {
|
||||
subsystem = LOG_SUBSYSTEM_DISPATCH,
|
||||
bucket = %bucket_name,
|
||||
target_count = target_ids_len,
|
||||
"Finished notify dispatch fan-out"
|
||||
"notify dispatch"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ impl EventNotifier {
|
||||
subsystem = LOG_SUBSYSTEM_DISPATCH,
|
||||
state = "targets_initialized",
|
||||
target_count = target_list_guard.len(),
|
||||
"Initialized notify runtime targets"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ impl NotifyRuleEngine {
|
||||
bucket = %bucket,
|
||||
state = "updated",
|
||||
event_count,
|
||||
"Updated bucket notification rules"
|
||||
"notify bucket rules state"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ impl NotifyRuleEngine {
|
||||
subsystem = LOG_SUBSYSTEM_RULE_ENGINE,
|
||||
bucket = %bucket,
|
||||
state = "removed",
|
||||
"Removed bucket notification rules"
|
||||
"notify bucket rules state"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ impl NotifyRuntimeFacade {
|
||||
subsystem = LOG_SUBSYSTEM_RUNTIME,
|
||||
target_id = %target_id,
|
||||
state = "replay_started",
|
||||
"Started notify replay worker"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
} else {
|
||||
debug!(
|
||||
@@ -76,7 +76,7 @@ impl NotifyRuntimeFacade {
|
||||
target_id = %target_id,
|
||||
state = "replay_skipped",
|
||||
reason = "no_store_configured",
|
||||
"Skipped notify replay worker startup"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
}
|
||||
}),
|
||||
@@ -122,7 +122,7 @@ impl NotifyRuntimeFacade {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_RUNTIME,
|
||||
state = "stopping",
|
||||
"Stopping notification runtime"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
|
||||
let active_targets = self.replay_workers.read().await.len();
|
||||
@@ -132,7 +132,7 @@ impl NotifyRuntimeFacade {
|
||||
subsystem = LOG_SUBSYSTEM_RUNTIME,
|
||||
state = "replay_stopping",
|
||||
active_targets,
|
||||
"Stopping notify replay workers"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
|
||||
{
|
||||
@@ -160,7 +160,7 @@ impl NotifyRuntimeFacade {
|
||||
component = LOG_COMPONENT_NOTIFY,
|
||||
subsystem = LOG_SUBSYSTEM_RUNTIME,
|
||||
state = "stopped",
|
||||
"Stopped notification runtime"
|
||||
"notify runtime lifecycle"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user