mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-09 22:59:59 +00:00
fix(obs): shut down global telemetry guard (#4430)
Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -37,6 +37,7 @@ pub fn run_process() {
|
||||
// Tracing may not be initialized when startup fails this early.
|
||||
emit_fatal_stderr("Server runtime failed", e);
|
||||
}
|
||||
let _ = crate::startup_runtime_sources::shutdown_observability_guard();
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
@@ -59,6 +60,7 @@ async fn async_main() -> Result<()> {
|
||||
Ok(result) => result,
|
||||
Err(e) => {
|
||||
emit_fatal_stderr("Command parse failed", e);
|
||||
let _ = crate::startup_runtime_sources::shutdown_observability_guard();
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::{
|
||||
use rustfs_common::GlobalReadiness;
|
||||
use rustfs_scanner::init_data_scanner;
|
||||
use std::{
|
||||
io::Result,
|
||||
io::{Error, Result},
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
sync::{
|
||||
Arc,
|
||||
@@ -149,6 +149,8 @@ pub(crate) async fn run_startup_runtime_lifecycle(lifecycle: StartupRuntimeLifec
|
||||
result = "stopped",
|
||||
"RustFS server stopped"
|
||||
);
|
||||
startup_runtime_sources::shutdown_observability_guard()
|
||||
.map_err(|err| Error::other(format!("shutdown_global_guard: {err}")))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,10 @@ pub(crate) fn set_observability_guard(guard: OtelGuard) -> Result<(), Observabil
|
||||
rustfs_obs::set_global_guard(guard)
|
||||
}
|
||||
|
||||
pub(crate) fn shutdown_observability_guard() -> Result<(), ObservabilityError> {
|
||||
rustfs_obs::shutdown_global_guard()
|
||||
}
|
||||
|
||||
pub(crate) fn observability_metric_enabled() -> bool {
|
||||
rustfs_obs::observability_metric_enabled()
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use crate::{
|
||||
startup_optional_runtime_sidecars::{
|
||||
OptionalRuntimeServices, prepare_optional_runtime_shutdowns, shutdown_optional_runtime_services,
|
||||
},
|
||||
startup_runtime_sources,
|
||||
};
|
||||
use rustfs_heal::shutdown_ahm_services;
|
||||
use rustfs_utils::get_env_bool_with_aliases;
|
||||
@@ -299,6 +300,17 @@ pub(crate) async fn run_embedded_server_shutdown(
|
||||
state = "stopped",
|
||||
"Embedded server state changed"
|
||||
);
|
||||
|
||||
if let Err(err) = startup_runtime_sources::shutdown_observability_guard() {
|
||||
warn!(
|
||||
component = LOG_COMPONENT_EMBEDDED,
|
||||
subsystem = LOG_SUBSYSTEM_EMBEDDED,
|
||||
event = EVENT_EMBEDDED_SHUTDOWN_CLEANUP_FAILED,
|
||||
service = "observability",
|
||||
error = %err,
|
||||
"Embedded shutdown cleanup failed"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user