RateLimitingSampler extends Sampler { public static Sampler create(int tracesPerSecond) { if (tracesPerSecond < 0) throw new IllegalArgumentException("tracesPerSecond < 0"); if (tracesPerSecond == 0) return Sampler.NEVER_SAMPLE; return new RateLimitingSampler(tracesPerSecond); } RateLimitingSampler(int tracesPerSecond); static Sampler create(int tracesPerSecond); @Override boolean isSampled(long ignoredTraceId);  }
@Test public void zeroMeansDropAllTraces() { assertThat(RateLimitingSampler.create(0)).isSameAs(Sampler.NEVER_SAMPLE); }
@Test(expected = IllegalArgumentException.class) public void tracesPerSecond_cantBeNegative() { RateLimitingSampler.create(-1); }