mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-20 01:27:02 +08:00
Use parent-based sampler by default
Closes gh-33821
This commit is contained in:
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…
Reference in New Issue
Block a user