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 reset to metrics #627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions jpos/src/main/java/org/jpos/util/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,25 @@ public void dumpHistograms (File dir, String prefix) {
public void setConversion(double conversion) {
this.conversion = conversion;
}

/**
* Reset any value counts accumulated thus far.
*/
public void reset() {
metrics.values()
.forEach(Histogram::reset);
}

/**
* Resets histograms whose keys start with the given prefix using the Histogram.reset() method.
*
* @param prefix the prefix used to filter histograms to reset
*/
public void reset(String prefix) {
metrics.entrySet()
.stream()
.filter(e -> e.getKey().startsWith(prefix))
.forEach(e -> e.getValue().reset());
}

}
Loading