fix: address correctness, safety, and concurrency issues (#2327)

Co-authored-by: heihutu <heihutu@gmail.com>
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
houseme
2026-03-30 00:30:57 +08:00
committed by GitHub
parent 860a37d3a8
commit 7172e151de
90 changed files with 20397 additions and 1228 deletions
+1 -4
View File
@@ -28,10 +28,7 @@ static HELP_CACHE: OnceLock<Mutex<HashMap<String, &'static str>>> = OnceLock::ne
fn intern_string(cache: &OnceLock<Mutex<HashMap<String, &'static str>>>, value: &str) -> &'static str {
let cache = cache.get_or_init(Default::default);
let mut cache = match cache.lock() {
Ok(guard) => guard,
Err(poisoned) => poisoned.into_inner(),
};
let mut cache = cache.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if let Some(existing) = cache.get(value) {
existing
+3 -2
View File
@@ -13,6 +13,7 @@
// limitations under the License.
use tokio_util::sync::CancellationToken;
use tracing::info;
/// Initializes the global metrics system. This should be called once at the start of the application.
/// The provided `CancellationToken` will be used to gracefully shut down the metrics system when needed.
@@ -33,7 +34,7 @@ use tokio_util::sync::CancellationToken;
/// ```
/// Note: This function should only be called once during the application's lifecycle. Calling it multiple times may lead to unexpected behavior.
pub fn init_metrics_system(token: CancellationToken) {
tracing::info!("init metrics system start");
info!("init metrics system start");
crate::collectors::init_metrics_collectors(token);
tracing::info!("init metrics system done");
info!("init metrics system done");
}