We are using GetOrRegister in a place where it can be called frequently. Using a sync.RWMutex and using RLock/RUnlock instead of Lock/Unlock can increase performance here:
Nevermind, it looks like we need to keep the lock for the entire duration of GetOrRegister or else you can have concurrent calls to it trying to register duplicate metrics.
We are using GetOrRegister in a place where it can be called frequently. Using a
sync.RWMutex
and usingRLock/RUnlock
instead ofLock/Unlock
can increase performance here:https://github.com/rcrowley/go-metrics/blob/master/registry.go#L80-L81