CompositeRegistry extends MetricRegistry { public void add(MetricRegistry registry) { Assert.checkArg(!(registry instanceof CompositeRegistry), String.format("registry: %s can not be a CompositeRegistry!", registry)); registries.add(registry); } CompositeRegistry(Clock clock); @Override void registerExtendedMetrics(); Collection<Registry> getRegistries(); void add(MetricRegistry registry); void remove(Registry registry); void clear(); @Override Gauge<T> gauge(Id id, Gauge<T> gauge); @Override void removeMetric(Id id); @Override Info info(Id id, Y info); @Override void register(Metric metric); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override MixinMetric mixinMetric(Id id); @Override X get(Id id); @Override Iterator<Metric> iterator();  }
@Test public void testGetCompositeCounter() { Registry r = NoopRegistry.INSTANCE; List<Registry> list = new ArrayList<Registry>(); list.add(r); CompositeCounter counter = new CompositeCounter(r.createId("xx"), list); counter.dec(1); counter.dec(); counter.inc(2); counter.inc(); Assert.assertEquals(0, counter.count()); }
@Test public void testGetCompositeTimer() { Registry r = NoopRegistry.INSTANCE; List<Registry> list = new ArrayList<Registry>(); list.add(r); Timer t = new CompositeTimer(r.createId("xx"), Clock.SYSTEM, list); t.record(100, TimeUnit.SECONDS); Assert.assertEquals(0, t.count()); Assert.assertEquals(0, t.totalTime()); }
@Test public void testGetCompositeDistributionSummary() { Registry r = NoopRegistry.INSTANCE; List<Registry> list = new ArrayList<Registry>(); list.add(r); DistributionSummary t = new CompositeDistributionSummary(r.createId("xx"), list); t.record(100); Assert.assertEquals(0, t.count()); Assert.assertEquals(0, t.totalAmount()); }