Closed sunng87 closed 3 weeks ago
Thanks for the report. If I'm understanding correctly, this request is an exact duplicate of #495. Can we close this duplicate and keep the discussion there? Or is there some important detail that is different here?
Yes, please. Let me add my comment to #495
This is similar request to https://github.com/tikv/rust-prometheus/issues/495
Currently, if we try to register the same metric to registry, we get an error and there is no way to fetch the metric from registry. This make it impossible to reuse the metric. Of course we can get before register but in concurrent scenario it can break.
I haven't looked very deep into the code, but the idea seems to be returning the already registerd metric as a member of
Error::AlreadyReg
. Also we need to update those macros to ensure that every time we can the macro with legal input, it should return a metric handle.Context: we hit this issue with opendal https://github.com/apache/opendal/issues/4854 in greptimedb https://github.com/GreptimeTeam/greptimedb/pull/2861
Let me know what do you think. Thank you!