MetricsCatcher { @Subscribe public void jobStarted(JobStartEvent data) { if (this.configuration.isJobsByType()) { registry.meter(prefix + ".job-meter-" + data.getType()) .mark(); jobs.start(data.getCorrelationId(), timer(prefix + ".job-timer-" + data.getType()).time()); registry.counter(prefix + ".jobs-active-" + data.getType() + "-count") .inc(); } } @Autowired  MetricsCatcher(MetricRegistry registry, EventBus bus, Configuration configuration); @Subscribe void requestStart(AddQuery<T> data); @Subscribe void requestComplete(RemoveQuery<T> data); @Subscribe void requestStart(AddLabelledQuery<T> data); @Subscribe void requestComplete(RemoveLabelledQuery<T> data); @Subscribe void finished(SystemData data); @Subscribe void jobStarted(JobStartEvent data); @Subscribe void jobComplete(JobCompleteEvent data); @Subscribe void error(ErrorCode c); @Subscribe void error(ErrorEvent event); @Subscribe void genericEvent(GenericEvent event);  }
@Test public void jobsMeterInc() { catcher.jobStarted(new JobStartEvent("10", "test")); assertThat(registry.meter(this.config.getPrefix() + ".job-meter-test") .getMeanRate(), greaterThan(0.0)); }
@Test public void jobsCounterInc() { catcher.jobStarted(new JobStartEvent("10", "test")); assertThat(registry.counter(this.config.getPrefix() + ".jobs-active-test-count") .getCount(), equalTo(1l)); }