@Test public void testDropwizardOverMaxCount() { MetricRegistry reg = new MetricRegistry(); LookoutConfig lookoutConfig = new LookoutConfig(); lookoutConfig.setProperty(LookoutConfig.LOOKOUT_MAX_METRICS_NUMBER, 1); DropWizardMetricsRegistry dwreg = new DropWizardMetricsRegistry(Clock.SYSTEM, reg, lookoutConfig); Counter counter1 = dwreg.counter(dwreg.createId("a.b")); Counter counter2 = dwreg.counter(dwreg.createId("a.b.c")); System.out.println(counter2.getClass().getCanonicalName()); Assert.assertTrue(counter2.getClass().getCanonicalName().contains("NoopCounter")); }
@Override public Counter counter(Id id) { if (overSize(id)) { return NoopRegistry.INSTANCE.counter(id); } final String name = toMetricName(id); return new DwMetricsCounter(clock(), id, impl.counter(name)); }
DropWizardMetricsRegistry extends MetricRegistry { @Override public Counter counter(Id id) { if (overSize(id)) { return NoopRegistry.INSTANCE.counter(id); } final String name = toMetricName(id); return new DwMetricsCounter(clock(), id, impl.counter(name)); } }
DropWizardMetricsRegistry extends MetricRegistry { @Override public Counter counter(Id id) { if (overSize(id)) { return NoopRegistry.INSTANCE.counter(id); } final String name = toMetricName(id); return new DwMetricsCounter(clock(), id, impl.counter(name)); } DropWizardMetricsRegistry();  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl);  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl,
                                     MetricConfig metricConfig); }
DropWizardMetricsRegistry extends MetricRegistry { @Override public Counter counter(Id id) { if (overSize(id)) { return NoopRegistry.INSTANCE.counter(id); } final String name = toMetricName(id); return new DwMetricsCounter(clock(), id, impl.counter(name)); } DropWizardMetricsRegistry();  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl);  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl,
                                     MetricConfig metricConfig); @Override Gauge<T> gauge(Id id, Gauge<T> gauge); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override void register(final Metric metric); @Override void removeMetric(Id id); @Override void propagate(String msg, Throwable t); @Override MixinMetric mixinMetric(Id id); @Override void registerExtendedMetrics(); @Override Info info(Id id, Y info); @Override X get(Id id); @Override Iterator<Metric> iterator(); boolean overSize(Id id); }
DropWizardMetricsRegistry extends MetricRegistry { @Override public Counter counter(Id id) { if (overSize(id)) { return NoopRegistry.INSTANCE.counter(id); } final String name = toMetricName(id); return new DwMetricsCounter(clock(), id, impl.counter(name)); } DropWizardMetricsRegistry();  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl);  DropWizardMetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl,
                                     MetricConfig metricConfig); @Override Gauge<T> gauge(Id id, Gauge<T> gauge); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override void register(final Metric metric); @Override void removeMetric(Id id); @Override void propagate(String msg, Throwable t); @Override MixinMetric mixinMetric(Id id); @Override void registerExtendedMetrics(); @Override Info info(Id id, Y info); @Override X get(Id id); @Override Iterator<Metric> iterator(); boolean overSize(Id id);  }