@Test public void testSample() { long startTime = System.currentTimeMillis(); String traceId = UUID.randomUUID().toString(); Span spanToAllow = Span.newBuilder(). setCustomer("dummy"). setStartMillis(startTime). setDuration(6). setName("testSpanName"). setSource("testsource"). setSpanId("testspanid"). setTraceId(traceId). build(); Span spanToDiscard = Span.newBuilder(). setCustomer("dummy"). setStartMillis(startTime). setDuration(4). setName("testSpanName"). setSource("testsource"). setSpanId("testspanid"). setTraceId(traceId). build(); SpanSampler sampler = new SpanSampler(new DurationSampler(5), true); assertTrue(sampler.sample(spanToAllow)); assertFalse(sampler.sample(spanToDiscard)); Counter discarded = Metrics.newCounter(new MetricName("SpanSamplerTest", "testSample", "discarded")); assertTrue(sampler.sample(spanToAllow, discarded)); assertEquals(0, discarded.count()); assertFalse(sampler.sample(spanToDiscard, discarded)); assertEquals(1, discarded.count()); }
public boolean sample(Span span) { return sample(span, null); }
SpanSampler { public boolean sample(Span span) { return sample(span, null); } }
SpanSampler { public boolean sample(Span span) { return sample(span, null); } SpanSampler(Sampler delegate, boolean alwaysSampleErrors); }
SpanSampler { public boolean sample(Span span) { return sample(span, null); } SpanSampler(Sampler delegate, boolean alwaysSampleErrors); boolean sample(Span span); boolean sample(Span span, @Nullable Counter discarded); }
SpanSampler { public boolean sample(Span span) { return sample(span, null); } SpanSampler(Sampler delegate, boolean alwaysSampleErrors); boolean sample(Span span); boolean sample(Span span, @Nullable Counter discarded);  }