/** * Delegates to {@link #rootSpanSamplingStrategy}'s {@link RootSpanSamplingStrategy#isNextRootSpanSampleable()} method to determine whether the next root span should be * sampled. * <br/> * NOTE: This method is not deterministic - you may get a different response every time you call it. Therefore you should not call this method multiple times for the same * root span. Call it once and store the result for a given root span. * * @return true when the next root span should be sampled, false otherwise. */ protected boolean isNextRootSpanSampleable() { return rootSpanSamplingStrategy.isNextRootSpanSampleable(); }
@Test public void isNextRootSpanSampleable_should_use_strategy() { // given: known sampling strategy that is set on the Tracer RootSpanSamplingStrategy mockStrategy = mock(RootSpanSamplingStrategy.class); Tracer.getInstance().setRootSpanSamplingStrategy(mockStrategy); // when: isNextRootSpanSampleable() is called Tracer.getInstance().isNextRootSpanSampleable(); // then: the strategy's isNextRootSpanSampleable() method should have been called verify(mockStrategy).isNextRootSpanSampleable(); }