TraceSampleRateWatcher extends ConfigChangeWatcher { public int getSampleRate() { return sampleRate.get(); } TraceSampleRateWatcher(ModuleProvider provider); @Override void notify(ConfigChangeEvent value); @Override String value(); int getSampleRate();  }
@Test(timeout = 20000) public void testDynamicUpdate() throws InterruptedException { ConfigWatcherRegister register = new MockConfigWatcherRegister(3); TraceSampleRateWatcher watcher = new TraceSampleRateWatcher(provider); register.registerConfigChangeWatcher(watcher); register.start(); while (watcher.getSampleRate() == 10000) { Thread.sleep(2000); } assertThat(watcher.getSampleRate(), is(9000)); assertThat(provider.getModuleConfig().getSampleRate(), is(10000)); }