metrics-rs / metrics

A metrics ecosystem for Rust.
MIT License
1.13k stars 158 forks source link

Improve handling of the global recorder instance #302

Closed Noratrieb closed 2 years ago

Noratrieb commented 2 years ago

This gets rid of the dangerous static mut, adds more comments about the code, relaxes the orderings and documents the unsoundness of the clear function.

It implements a small once_cell-like abstraction.

I also noticed that the whole #[cfg(atomic_cas)] seems pretty pointless since this crate doesn't support no_std anyways.

About clear_recorder: This function was unsound before as well, since the following interleaving was possible:

tobz commented 2 years ago

Everything checked out performance-wise. 👍🏻

Thank you for your contribution!

tobz commented 2 years ago

Released in metrics@v0.19.0 (along with other workspace crate releases to move to the new minor.)