CollectorSampler { public static CollectorSampler create(float rate) { if (rate < 0 || rate > 1) throw new IllegalArgumentException("rate should be between 0 and 1: was " + rate); final long boundary = (long) (Long.MAX_VALUE * rate); return new CollectorSampler() { @Override protected long boundary() { return boundary; } }; } protected  CollectorSampler(); static CollectorSampler create(float rate); boolean isSampled(String hexTraceId, boolean debug); @Override String toString(); static final CollectorSampler ALWAYS_SAMPLE; }
@Test public void rateCantBeNegative() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("rate should be between 0 and 1: was -1.0"); CollectorSampler.create(-1.0f); }
@Test public void rateCantBeOverOne() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("rate should be between 0 and 1: was 1.1"); CollectorSampler.create(1.1f); }