Use parent-based sampler by default

Closes gh-33821
pull/33711/head
Moritz Halbritter 2 years ago
parent ae79c60619
commit 31ca94833a

@ -112,7 +112,8 @@ public class OpenTelemetryAutoConfiguration {
@Bean
@ConditionalOnMissingBean
Sampler otelSampler() {
return Sampler.traceIdRatioBased(this.tracingProperties.getSampling().getProbability());
Sampler rootSampler = Sampler.traceIdRatioBased(this.tracingProperties.getSampling().getProbability());
return Sampler.parentBased(rootSampler);
}
@Bean

@ -80,6 +80,15 @@ class OpenTelemetryAutoConfigurationTests {
});
}
@Test
void samplerIsParentBased() {
this.contextRunner.run((context) -> {
Sampler sampler = context.getBean(Sampler.class);
assertThat(sampler).isNotNull();
assertThat(sampler.getDescription()).startsWith("ParentBased{");
});
}
@ParameterizedTest
@ValueSource(strings = { "io.micrometer.tracing.otel", "io.opentelemetry.sdk", "io.opentelemetry.api" })
void shouldNotSupplyBeansIfDependencyIsMissing(String packageName) {

Loading…
Cancel
Save