@Test public void maintainsDataBetweenRequests() { ResponseCodeSupplier responseCodeSupplier = new ResponseCodeSupplier(metricRegistry, COUNTER, "foo.bar", true); metricRegistry.counter("foo.bar.200").inc(1234); Map<String, Integer> result = responseCodeSupplier.get(); assertThat(result.get("200"), is(1234)); assertThat(result.get("2xx"), is(1234)); result = responseCodeSupplier.get(); assertThat(result.get("200"), is(1234)); assertThat(result.get("2xx"), is(1234)); }
@Override public Map<String, Integer> get() { resetAggregates(); if (statusMetricType == COUNTER) { updateFromMetrics(metrics.getCounters(prefixFilter)); } else if (statusMetricType == METER) { updateFromMetrics(metrics.getMeters(prefixFilter)); } addAggregatesToMap(responseCodes); return responseCodes; }
ResponseCodeSupplier implements Supplier<Map<String, Integer>> { @Override public Map<String, Integer> get() { resetAggregates(); if (statusMetricType == COUNTER) { updateFromMetrics(metrics.getCounters(prefixFilter)); } else if (statusMetricType == METER) { updateFromMetrics(metrics.getMeters(prefixFilter)); } addAggregatesToMap(responseCodes); return responseCodes; } }
ResponseCodeSupplier implements Supplier<Map<String, Integer>> { @Override public Map<String, Integer> get() { resetAggregates(); if (statusMetricType == COUNTER) { updateFromMetrics(metrics.getCounters(prefixFilter)); } else if (statusMetricType == METER) { updateFromMetrics(metrics.getMeters(prefixFilter)); } addAggregatesToMap(responseCodes); return responseCodes; } ResponseCodeSupplier(MetricRegistry metrics, StatusMetricType statusMetricType, String prefix, boolean includeNonErrorCodes); }
ResponseCodeSupplier implements Supplier<Map<String, Integer>> { @Override public Map<String, Integer> get() { resetAggregates(); if (statusMetricType == COUNTER) { updateFromMetrics(metrics.getCounters(prefixFilter)); } else if (statusMetricType == METER) { updateFromMetrics(metrics.getMeters(prefixFilter)); } addAggregatesToMap(responseCodes); return responseCodes; } ResponseCodeSupplier(MetricRegistry metrics, StatusMetricType statusMetricType, String prefix, boolean includeNonErrorCodes); @Override Map<String, Integer> get(); }
ResponseCodeSupplier implements Supplier<Map<String, Integer>> { @Override public Map<String, Integer> get() { resetAggregates(); if (statusMetricType == COUNTER) { updateFromMetrics(metrics.getCounters(prefixFilter)); } else if (statusMetricType == METER) { updateFromMetrics(metrics.getMeters(prefixFilter)); } addAggregatesToMap(responseCodes); return responseCodes; } ResponseCodeSupplier(MetricRegistry metrics, StatusMetricType statusMetricType, String prefix, boolean includeNonErrorCodes); @Override Map<String, Integer> get();  }