diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index cd6ae757e..a1e5ff2d8 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -40,6 +40,7 @@ |spring.sleuth.rxjava.schedulers.ignoredthreads | [HystrixMetricPoller, ^RxComputation.*$] | Thread names for which spans will not be sampled. |spring.sleuth.sampler.probability | | Probability of requests that should be sampled. E.g. 1.0 - 100% requests should be sampled. The precision is whole-numbers only (i.e. there's no support for 0.1% of the traces). |spring.sleuth.sampler.rate | 10 | A rate per second can be a nice choice for low-traffic endpoints as it allows you surge protection. For example, you may never expect the endpoint to get more than 50 requests per second. If there was a sudden surge of traffic, to 5000 requests per second, you would still end up with 50 traces per second. Conversely, if you had a percentage, like 10%, the same surge would end up with 500 traces per second, possibly overloading your storage. Amazon X-Ray includes a rate-limited sampler (named Reservoir) for this purpose. Brave has taken the same approach via the {@link brave.sampler.RateLimitingSampler}. +|spring.sleuth.sampler.refresh.enabled | true | Enable refresh scope for sampler. |spring.sleuth.scheduled.enabled | true | Enable tracing for {@link org.springframework.scheduling.annotation.Scheduled}. |spring.sleuth.scheduled.skip-pattern | | Pattern for the fully qualified name of a class that should be skipped. |spring.sleuth.supports-join | true | True means the tracing system supports sharing a span ID between a client and server. diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/sampler/SamplerAutoConfigurationTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/sampler/SamplerAutoConfigurationTests.java index f1cbf6c6f..a8c86de0a 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/sampler/SamplerAutoConfigurationTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/sampler/SamplerAutoConfigurationTests.java @@ -60,27 +60,36 @@ public class SamplerAutoConfigurationTests { @Test void should_use_RateLimitedSampler_withTracingCustomizer() { - this.contextRunner.withUserConfiguration(WithTracingCustomizer.class).run((context -> { - final Sampler bean = context.getBean(Sampler.class); - BDDAssertions.then(bean).isInstanceOf(RateLimitingSampler.class); - })); + this.contextRunner.withUserConfiguration(WithTracingCustomizer.class) + .run((context -> { + final Sampler bean = context.getBean(Sampler.class); + BDDAssertions.then(bean).isInstanceOf(RateLimitingSampler.class); + })); } @Test void should_use_refresh_scope_sampler_when_no_property_passed_and_refresh_scope_present() { - this.contextRunner.withUserConfiguration(WithTracingCustomizer.class, WithRefreshScope.class).run((context -> { - BDDAssertions.then(context.containsBean("defaultTraceSampler")).as("refresh scope bean should be set") - .isTrue(); - BDDAssertions.then(context.containsBean("defaultNonRefreshScopeTraceSampler")) - .as("non refresh scope bean should not be picked").isFalse(); - })); + this.contextRunner.withUserConfiguration(WithTracingCustomizer.class, + WithRefreshScope.class).run((context -> { + BDDAssertions.then(context.containsBean("defaultTraceSampler")) + .as("refresh scope bean should be set").isTrue(); + BDDAssertions + .then(context + .containsBean("defaultNonRefreshScopeTraceSampler")) + .as("non refresh scope bean should not be picked").isFalse(); + })); } @Test void should_use_non_refresh_scope_sampler_when_property_passed_and_refresh_scope_present() { - this.contextRunner.withUserConfiguration(WithTracingCustomizer.class, WithRefreshScope.class) - .withPropertyValues("spring.sleuth.sampler.refresh.enabled=false").run((context -> { - BDDAssertions.then(context.containsBean("defaultNonRefreshScopeTraceSampler")) + this.contextRunner + .withUserConfiguration(WithTracingCustomizer.class, + WithRefreshScope.class) + .withPropertyValues("spring.sleuth.sampler.refresh.enabled=false") + .run((context -> { + BDDAssertions + .then(context + .containsBean("defaultNonRefreshScopeTraceSampler")) .as("non refresh scope bean should be picked").isTrue(); BDDAssertions.then(context.containsBean("defaultTraceSampler")) .as("refresh scope bean should not be set").isFalse();