mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 05:06:28 +00:00
refactor(logging): standardize protocol and observability events (#3419)
* refactor(logging): standardize object capacity events * refactor(logging): standardize protocol server events * refactor(logging): standardize swift protocol events * refactor(logging): standardize observability events * refactor(logging): move masking helper and extend guardrails
This commit is contained in:
@@ -62,6 +62,10 @@ use std::collections::HashMap;
|
||||
use tracing::debug;
|
||||
use tracing::error;
|
||||
|
||||
const LOG_COMPONENT_PROTOCOLS: &str = "protocols";
|
||||
const LOG_SUBSYSTEM_SWIFT_OBJECT: &str = "swift_object";
|
||||
const EVENT_SWIFT_OBJECT_STORAGE_STATE: &str = "swift_object_storage_state";
|
||||
|
||||
/// Maximum number of metadata headers allowed per object (Swift standard)
|
||||
const MAX_METADATA_COUNT: usize = 90;
|
||||
|
||||
@@ -258,7 +262,15 @@ fn validate_metadata(metadata: &HashMap<String, String>) -> SwiftResult<()> {
|
||||
/// This prevents information disclosure vulnerabilities.
|
||||
fn sanitize_storage_error<E: std::fmt::Display>(operation: &str, error: E) -> SwiftError {
|
||||
// Log detailed error server-side
|
||||
error!("Storage operation '{}' failed: {}", operation, error);
|
||||
error!(
|
||||
event = EVENT_SWIFT_OBJECT_STORAGE_STATE,
|
||||
component = LOG_COMPONENT_PROTOCOLS,
|
||||
subsystem = LOG_SUBSYSTEM_SWIFT_OBJECT,
|
||||
operation = %operation,
|
||||
error = %error,
|
||||
result = "failed",
|
||||
"swift object storage state changed"
|
||||
);
|
||||
|
||||
// Return generic error to client
|
||||
SwiftError::InternalServerError(format!("{} operation failed", operation))
|
||||
@@ -334,7 +346,14 @@ where
|
||||
// Store the fully qualified target (container/object)
|
||||
let target_value = symlink_target.to_header_value(container);
|
||||
user_metadata.insert("x-object-symlink-target".to_string(), target_value);
|
||||
debug!("Creating symlink to target: {}", user_metadata.get("x-object-symlink-target").unwrap());
|
||||
debug!(
|
||||
event = EVENT_SWIFT_OBJECT_STORAGE_STATE,
|
||||
component = LOG_COMPONENT_PROTOCOLS,
|
||||
subsystem = LOG_SUBSYSTEM_SWIFT_OBJECT,
|
||||
state = "symlink_target_recorded",
|
||||
target = %user_metadata.get("x-object-symlink-target").unwrap(),
|
||||
"swift object storage state changed"
|
||||
);
|
||||
}
|
||||
|
||||
// 9. Validate metadata limits
|
||||
|
||||
Reference in New Issue
Block a user