Skip to content
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

Add possibility to reset metric value #60

Open
rc-mairovichaa opened this issue Sep 23, 2024 · 0 comments
Open

Add possibility to reset metric value #60

rc-mairovichaa opened this issue Sep 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@rc-mairovichaa
Copy link
Collaborator

rc-mairovichaa commented Sep 23, 2024

To reduce time required for test runs application context is reused sometimes in different tests.
It is highly relevant for integration tests.
By "application context" here could be considered Spring-context.

It's suggested to introduce "reset" method to metrics to be able to start from scratch in a particular test case if it's needed.
Also it makes sense to add such method on MetricRegistry level (moreover, maybe it's enough - no need to add for each Metric type).

For example

MetricRegistry registry = new DefaultMetricRegistry();
Counter counter = registry.counter(withName("counter"));

counter.inc();
counter.inc();
counter.forEach(instance -> {
    Long v = (Long)instance.valueOf(COUNT);
    
    // Current value: 2
    System.out.println("Current value: " + v);
});
counter.reset();
// or
registry.resetMetrics();

// Current value: 0
System.out.println("Current value: " + v);
@rc-mairovichaa rc-mairovichaa added the enhancement New feature or request label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant