public boolean shouldSample(String service, int sample, int duration) {
        SamplingPolicy samplingPolicy = this.samplingPolicySettings.get().get(service);
        if (samplingPolicy == null) {
            return shouldSampleByDefault(sample, duration);
        }
        return shouldSampleService(samplingPolicy, sample, duration);
    }
@Test
    @Timeout(20)
    public void testTraceLatencyThresholdDynamicUpdate() throws InterruptedException {
        ConfigWatcherRegister register = new TraceLatencyThresholdMockConfigWatcherRegister(3);

        TraceSamplingPolicyWatcher watcher = new TraceSamplingPolicyWatcher(moduleConfig, provider);
        register.registerConfigChangeWatcher(watcher);
        register.start();
        // Default duration is -1, so 3000 must not be sampled,until updating to 3000
        while (!watcher.shouldSample("", 10000, 3000)) {
            Thread.sleep(2000);
        }
        Assertions.assertTrue(watcher.shouldSample("", 10000, 3001));
    }