Skip to content

Add possibility to reset metric value #60

@rc-mairovichaa

Description

@rc-mairovichaa

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions