diff --git a/jpos/src/main/java/org/jpos/util/Metrics.java b/jpos/src/main/java/org/jpos/util/Metrics.java index e6fb389cc4..752bc7a6d4 100644 --- a/jpos/src/main/java/org/jpos/util/Metrics.java +++ b/jpos/src/main/java/org/jpos/util/Metrics.java @@ -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()); + } + }