@Override
    public boolean shouldSample() {
        long now = nanoClock.nanoTimeNow();
        long period = now / periodLengthInNanos;
        synchronized (this) {
            if (period != currentSamplingPeriod) {
                currentSamplingPeriod = period;
                samplesInCurrentPeriod = 1;
                return true;
            }
            if (samplesInCurrentPeriod >= maxSamplesPerPeriod) {
                return false;
            }
            ++samplesInCurrentPeriod;
            return true;
        }
    }
Very basic sampling strategy which allows for sampling N requests within a fixed
time window. No attempt is made to distribute the samples evenly within the time
period; this is on a first-come, first-serve basis.
vespajlib/src/main/java/ai/vespa/sampling/MaxSamplesPerPeriod.java