@Test public void testSamplingBoundariesNegative() { double samplingRate = 0.5; long halfwayBoundary = -0x4000000000000000L; Sampler sampler = new ProbabilisticSampler(samplingRate); assertTrue(sampler.sample("", halfwayBoundary).isSampled()); assertFalse(sampler.sample("", halfwayBoundary - 1).isSampled()); }
@Override public SamplingStatus sample(String operation, long id) { if (id > 0) { return SamplingStatus.of(id <= this.positiveSamplingBoundary, tags); } else { return SamplingStatus.of(id >= this.negativeSamplingBoundary, tags); } }
ProbabilisticSampler implements Sampler { @Override public SamplingStatus sample(String operation, long id) { if (id > 0) { return SamplingStatus.of(id <= this.positiveSamplingBoundary, tags); } else { return SamplingStatus.of(id >= this.negativeSamplingBoundary, tags); } } }
ProbabilisticSampler implements Sampler { @Override public SamplingStatus sample(String operation, long id) { if (id > 0) { return SamplingStatus.of(id <= this.positiveSamplingBoundary, tags); } else { return SamplingStatus.of(id >= this.negativeSamplingBoundary, tags); } } ProbabilisticSampler(double samplingRate); }
ProbabilisticSampler implements Sampler { @Override public SamplingStatus sample(String operation, long id) { if (id > 0) { return SamplingStatus.of(id <= this.positiveSamplingBoundary, tags); } else { return SamplingStatus.of(id >= this.negativeSamplingBoundary, tags); } } ProbabilisticSampler(double samplingRate); @Override SamplingStatus sample(String operation, long id); @Override boolean equals(Object other); @Override void close(); }
ProbabilisticSampler implements Sampler { @Override public SamplingStatus sample(String operation, long id) { if (id > 0) { return SamplingStatus.of(id <= this.positiveSamplingBoundary, tags); } else { return SamplingStatus.of(id >= this.negativeSamplingBoundary, tags); } } ProbabilisticSampler(double samplingRate); @Override SamplingStatus sample(String operation, long id); @Override boolean equals(Object other); @Override void close(); static final double DEFAULT_SAMPLING_PROBABILITY; static final String TYPE; }