Gauges in Dropwizard metrics refer to some executable code. That
code might depend on some resources. If you were to call getOrAdd
you are passing in second block of code. Call getOrAdd often enough
and you have a resource leak.
If you are sure you want to replace a gauge, the only thing you can
do is remove the existing gauge and add a new one.
BTW, there is almost no good reason ever to use the return value
from newGauge (nor from getOrAdd).
Op 16-03-2020 om 07:25 schreef Aime