rcrowley / go-metrics

Go port of Coda Hale's Metrics library
Other
3.43k stars 493 forks source link

Locks missing on Registry's Each and GetAll functions => concurrent reads/writes in registry map #282

Open jo-me opened 3 years ago

jo-me commented 3 years ago

Hi,

several times I've seen exceptions that there are concurrent reads and writes on a map. The map in question is registry.metrics. This apparently happens in the case that values are iterated in the map while new ones are added by GetOrRegister() or Register().

I assume this is due to the fact that Get()/Register()/GetOrRegister() functions all use locking while Each() and GetAll() don't.

Could this be added so that the map access can happen thread-safe?