client_rust icon indicating copy to clipboard operation
client_rust copied to clipboard

Add .get() to Family hashmap wrapper

Open JaydenElliott opened this issue 1 year ago • 2 comments

I have come across a few instances were I would like to check if a particular metric exists in the metric Family without creating a new entry if it doesn't. This PR simply exposes the HashMap::get() function to allow for match metric_family.get() type logic.

Let me know if there is anything else needed to get this change merged.

JaydenElliott avatar Mar 14 '23 00:03 JaydenElliott

Thanks for the pull request.

In order for me to better understand the feature request, mind expanding on your concrete use-cases for this method?

mxinden avatar Mar 23 '23 12:03 mxinden

https://github.com/prometheus/client_rust/issues/131#issuecomment-1481962341 describes the use case (allows me to access the metrics of a family to do comparisons against, or use to trigger logic without modifying the underlying data structure).

JaydenElliott avatar Mar 23 '23 22:03 JaydenElliott