-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to remove all metrics in the defaultRegistry #950
Comments
You could create a new Does that work for you? |
This does work for me I had to do a small refactor so that our metric class by default uses the default registry but then during tests we optionally pass The above solves my immediate issue although it would be nice if a clear()/reset() function existed on the prometheus registry for just this purpose so we don't have to expose this for testing. If the defaultRegistry in PrometheusRegistry was exposed for users to overwrite that would also work but maybe this causes other issues? |
Hi, I also ran into this problem. Our metrics can be enabled or disabled based on a user's request so I need to unregister all registered collectors on such a request. It was possible in I will provide PR with the |
Having a method to clear the registry would be really helpful for tests. Sure we can inject a new |
PrometheusRegistry |
I'd love to see that added back as well. I was trying to upgrade the Java client in the Zookeeper project, however I am struggling to refactor the tests to make them work with a new |
Hello I was trying to figure out a good way to test some metrics in our application but I can't find a good way to clean out the default registry since it's not recreated during tests with mvn. This causes some tests to fail if for instance you use the same "test_metric" name twice. Does anyone have any example to clear out the registry as I couldn't find anything when looking through the code.
It looks like this is not possible based on this. So i guess my general question is how does one test with this library in use?
The text was updated successfully, but these errors were encountered: