mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-22 04:16:38 +00:00
chore(io-metrics): make the server label injected, drop two leaf-violating deps (#6051)
This commit is contained in:
@@ -164,6 +164,9 @@ pub(crate) async fn local_node_name() -> String {
|
||||
}
|
||||
|
||||
pub(crate) async fn set_local_node_name(node_name: String) {
|
||||
// Also stamp the internode-metrics server label: io-metrics is a leaf
|
||||
// crate and no longer resolves node identity itself (backlog#1834).
|
||||
rustfs_io_metrics::internode_metrics::set_internode_server_label(node_name.as_str());
|
||||
rustfs_common::set_global_local_node_name(&node_name).await;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,31 +33,23 @@ default = []
|
||||
hotpath = [
|
||||
"hotpath/hotpath",
|
||||
"hotpath/tokio",
|
||||
"rustfs-common/hotpath",
|
||||
"rustfs-s3-ops/hotpath",
|
||||
"rustfs-utils/hotpath",
|
||||
]
|
||||
hotpath-alloc = [
|
||||
"hotpath",
|
||||
"hotpath/hotpath-alloc",
|
||||
"rustfs-common/hotpath-alloc",
|
||||
"rustfs-s3-ops/hotpath-alloc",
|
||||
"rustfs-utils/hotpath-alloc",
|
||||
]
|
||||
hotpath-cpu = [
|
||||
"hotpath",
|
||||
"hotpath/hotpath-cpu",
|
||||
"rustfs-common/hotpath-cpu",
|
||||
"rustfs-s3-ops/hotpath-cpu",
|
||||
"rustfs-utils/hotpath-cpu",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
hotpath.workspace = true
|
||||
metrics = { workspace = true }
|
||||
rustfs-common = { workspace = true }
|
||||
rustfs-s3-ops = { workspace = true }
|
||||
rustfs-utils = { workspace = true, features = ["ip"] }
|
||||
num_cpus = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] }
|
||||
|
||||
@@ -196,22 +196,19 @@ pub const INTERNODE_OPERATION_METRICS: &[InternodeOperationMetricDescriptor] = &
|
||||
},
|
||||
];
|
||||
|
||||
static STABLE_SERVER_LABEL: OnceLock<String> = OnceLock::new();
|
||||
|
||||
/// Injects the stable server label (node name or address) stamped on
|
||||
/// internode metrics. The runtime calls this when the local node name is
|
||||
/// published (see ecstore's `set_local_node_name`); the first write wins.
|
||||
/// io-metrics is a leaf crate and no longer resolves node identity itself
|
||||
/// (backlog#1834) — before injection the label reads "unset".
|
||||
pub fn set_internode_server_label(label: impl Into<String>) {
|
||||
let _ = STABLE_SERVER_LABEL.set(label.into());
|
||||
}
|
||||
|
||||
fn current_server_label() -> &'static str {
|
||||
static STABLE_SERVER_LABEL: OnceLock<String> = OnceLock::new();
|
||||
static FALLBACK_SERVER_LABEL: LazyLock<String> = LazyLock::new(rustfs_utils::get_local_ip_with_default);
|
||||
|
||||
if let Some(server) = STABLE_SERVER_LABEL.get() {
|
||||
return server.as_str();
|
||||
}
|
||||
|
||||
if let Some(server) = rustfs_common::try_get_global_local_node_name() {
|
||||
let _ = STABLE_SERVER_LABEL.set(server);
|
||||
if let Some(server) = STABLE_SERVER_LABEL.get() {
|
||||
return server.as_str();
|
||||
}
|
||||
}
|
||||
|
||||
FALLBACK_SERVER_LABEL.as_str()
|
||||
STABLE_SERVER_LABEL.get().map(String::as_str).unwrap_or("unset")
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
|
||||
Reference in New Issue
Block a user