Another footgun that I discovered the hard way (production) is to get_or_create multiple metrics within a family and assign to multiple variables and then deadlock. It isn't apparent that a lock is held and returned. Perhaps renaming get_or_create to get_or_create_with_lock would be an improvement, or provide a closure to get_or_create.
This then keeps the scope of the lock to local.
I realise there is Rustdoc on this, but that's easy to be missed.
Another footgun that I discovered the hard way (production) is to
get_or_createmultiple metrics within a family and assign to multiple variables and then deadlock. It isn't apparent that a lock is held and returned. Perhaps renamingget_or_createtoget_or_create_with_lockwould be an improvement, or provide a closure toget_or_create.This then keeps the scope of the lock to local.
I realise there is Rustdoc on this, but that's easy to be missed.