DeclarativeSampler implements SamplerFunction<M> { @Deprecated public Sampler toSampler(M method) { return toSampler(method, Sampler.NEVER_SAMPLE); } DeclarativeSampler(); static DeclarativeSampler<M> createWithProbability(
    ProbabilityOfMethod<M> probabilityOfMethod); static DeclarativeSampler<M> createWithRate(RateOfMethod<M> rateOfMethod); @Override @Nullable Boolean trySample(@Nullable M method); static DeclarativeSampler<M> create(RateForMethod<M> rateForMethod); @Deprecated Sampler toSampler(M method); @Deprecated Sampler toSampler(M method, Sampler fallback); @Deprecated SamplingFlags sample(@Nullable M method);  }
@Test public void toSampler() { assertThat(declarativeSampler.toSampler(traced(1.0f, 0, true)).isSampled(0L)) .isTrue(); assertThat(declarativeSampler.toSampler(traced(0.0f, 0, true)).isSampled(0L)) .isFalse(); assertThat(declarativeSampler.toSampler(traced(1.0f, 0, false)).isSampled(0L)) .isFalse(); }
@Test public void toSampler_fallback() { Sampler withFallback = declarativeSampler.toSampler(traced(0.0f, 0, false), Sampler.ALWAYS_SAMPLE); assertThat(withFallback.isSampled(0L)) .isTrue(); }
@Test public void toSampler_fallback_notUsed() { Sampler withFallback = declarativeSampler.toSampler(traced(1.0f, 0, true), Sampler.NEVER_SAMPLE); assertThat(withFallback.isSampled(0L)) .isTrue(); }