mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-06 10:48:08 +00:00
fix(observability): keep lock PID resource attribution
Remove only the process_pid datapoint label from RustFS process metrics, leaving the shared process.pid resource available to sibling metrics and lock histograms. Lock metrics continue using resource-to-telemetry conversion without mutating the shared resource. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com>
This commit is contained in:
@@ -32,11 +32,11 @@ processors:
|
||||
error_mode: ignore
|
||||
metric_statements:
|
||||
# RustFS process metrics already expose process_pid as a metric label.
|
||||
# Keep process.pid on other metrics (including lock histograms) so their
|
||||
# Prometheus series remain attributable across process restarts.
|
||||
# Remove only the duplicate datapoint label and keep the shared resource
|
||||
# process.pid available to sibling metrics and lock histograms.
|
||||
- context: metric
|
||||
statements:
|
||||
- delete_key(resource.attributes, "process.pid") where IsMatch(name, "^rustfs_system_process_")
|
||||
- delete_key(attributes, "process_pid") where IsMatch(name, "^rustfs_system_process_")
|
||||
transform/logs:
|
||||
error_mode: ignore
|
||||
log_statements:
|
||||
|
||||
@@ -14,12 +14,8 @@
|
||||
|
||||
//! Lock optimization metrics recording functions.
|
||||
|
||||
use std::sync::LazyLock;
|
||||
use std::time::Duration;
|
||||
|
||||
const PROCESS_PID_LABEL: &str = "process_pid";
|
||||
static PROCESS_PID_VALUE: LazyLock<String> = LazyLock::new(|| std::process::id().to_string());
|
||||
|
||||
/// Record lock optimization enabled.
|
||||
#[inline(always)]
|
||||
pub fn record_lock_optimization_enabled(enabled: bool) {
|
||||
@@ -153,8 +149,7 @@ pub fn record_object_lock_diag_acquire_duration(op: &'static str, mode: &'static
|
||||
histogram!(
|
||||
"rustfs_object_lock_diag_acquire_duration_seconds",
|
||||
"op" => op,
|
||||
"mode" => mode,
|
||||
PROCESS_PID_LABEL => PROCESS_PID_VALUE.as_str()
|
||||
"mode" => mode
|
||||
)
|
||||
.record(duration.as_secs_f64());
|
||||
}
|
||||
@@ -166,8 +161,7 @@ pub fn record_object_lock_diag_hold_duration(op: &'static str, mode: &'static st
|
||||
histogram!(
|
||||
"rustfs_object_lock_diag_hold_duration_seconds",
|
||||
"op" => op,
|
||||
"mode" => mode,
|
||||
PROCESS_PID_LABEL => PROCESS_PID_VALUE.as_str()
|
||||
"mode" => mode
|
||||
)
|
||||
.record(duration.as_secs_f64());
|
||||
}
|
||||
@@ -179,8 +173,7 @@ pub fn record_object_lock_diag_slow_acquire(op: &'static str, mode: &'static str
|
||||
counter!(
|
||||
"rustfs_object_lock_diag_slow_acquire_total",
|
||||
"op" => op,
|
||||
"mode" => mode,
|
||||
PROCESS_PID_LABEL => PROCESS_PID_VALUE.as_str()
|
||||
"mode" => mode
|
||||
)
|
||||
.increment(1);
|
||||
}
|
||||
@@ -192,8 +185,7 @@ pub fn record_object_lock_diag_slow_hold(op: &'static str, mode: &'static str) {
|
||||
counter!(
|
||||
"rustfs_object_lock_diag_slow_hold_total",
|
||||
"op" => op,
|
||||
"mode" => mode,
|
||||
PROCESS_PID_LABEL => PROCESS_PID_VALUE.as_str()
|
||||
"mode" => mode
|
||||
)
|
||||
.increment(1);
|
||||
}
|
||||
@@ -439,16 +431,6 @@ mod tests {
|
||||
recorder.saw_histogram_named("rustfs_object_lock_diag_acquire_duration_seconds"),
|
||||
"expected object lock diagnostics acquire histogram to be emitted"
|
||||
);
|
||||
let histogram_keys = recorder.histograms.lock().expect("histogram keys should be lockable");
|
||||
let key = histogram_keys
|
||||
.iter()
|
||||
.find(|key| key.name() == "rustfs_object_lock_diag_acquire_duration_seconds")
|
||||
.expect("acquire histogram key should be registered");
|
||||
assert!(
|
||||
key.labels()
|
||||
.any(|label| label.key() == PROCESS_PID_LABEL && label.value() == std::process::id().to_string()),
|
||||
"lock histogram must carry the emitting process PID"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user