LookoutSpringBootMetricsImpl implements CounterService, GaugeService { @Override public void reset(String metricName) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_COUNTER_PREFIX, metricName); Id id = this.registry.createId(metricName); this.registry.removeMetric(id); } LookoutSpringBootMetricsImpl(Registry registry); @Override void increment(String metricName); @Override void decrement(String metricName); @Override void reset(String metricName); @Override void submit(String metricName, double value); static final String LOOKOUT_COUNTER_PREFIX; static final String LOOKOUT_GAUGE_PREFIX; }
@Test public void testReset() throws Exception { String originName = "metricName1"; String metricName = originName; this.counterService.increment(originName); metricName = LookoutSpringBootMetricsImpl.LOOKOUT_COUNTER_PREFIX + metricName; Metric metric = this.lookoutRegistryMetricReader.findOne(metricName); assertTrue(metric != null); this.counterService.reset(originName); assertTrue(this.lookoutRegistryMetricReader.findOne(metricName) == null); }