ActivityMetrics { public static void mountSubRegistry(String mountPrefix, MetricRegistry subRegistry) { new MetricsRegistryMount(getMetricRegistry(),subRegistry,mountPrefix); } private  ActivityMetrics(); static Timer timer(ActivityDef activityDef, String name); static Histogram histogram(ActivityDef activityDef, String name); static Counter counter(ActivityDef activityDef, String name); static Meter meter(ActivityDef activityDef, String name); @SuppressWarnings("unchecked") static Gauge<T> gauge(ActivityDef activityDef, String name, Gauge<T> gauge); @SuppressWarnings("unchecked") static Gauge<T> gauge(ScriptContext scriptContext, String name, Gauge<T> gauge); static MetricRegistry getMetricRegistry(); static void addHistoLogger(String sessionName, String pattern, String filename, String interval); static void addStatsLogger(String sessionName, String pattern, String filename, String interval); static void addClassicHistos(String sessionName, String pattern, String prefix, String interval); static void closeMetrics(boolean showChart); static void reportTo(PrintStream out); static void mountSubRegistry(String mountPrefix, MetricRegistry subRegistry); static void removeActivityMetrics(ActivityDef activityDef); static MetricFilter METRIC_FILTER; }
@Test public void testMountSubRegistry() throws Exception { MetricRegistry r1 = new MetricRegistry(); r1.counter("counter1"); int extant = ActivityMetrics.getMetricRegistry().getMetrics().size(); ActivityMetrics.mountSubRegistry("aprefixhere.",r1); Map<String, Metric> metrics = ActivityMetrics.getMetricRegistry().getMetrics(); assertThat(metrics).containsKey("aprefixhere.counter1"); assertThat(metrics).hasSize(extant+1); r1.counter("counter2"); metrics = ActivityMetrics.getMetricRegistry().getMetrics(); assertThat(metrics).hasSize(extant+2); assertThat(metrics).containsKey("aprefixhere.counter2"); r1.remove("counter1"); metrics = ActivityMetrics.getMetricRegistry().getMetrics(); assertThat(metrics).hasSize(extant+1); assertThat(metrics).containsKey("aprefixhere.counter2"); r1.remove("counter2"); metrics = ActivityMetrics.getMetricRegistry().getMetrics(); assertThat(metrics).hasSize(extant); }