mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +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
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
Sampler otelSampler() {
|
Sampler otelSampler() {
|
||||||
return Sampler.traceIdRatioBased(this.tracingProperties.getSampling().getProbability());
|
Sampler rootSampler = Sampler.traceIdRatioBased(this.tracingProperties.getSampling().getProbability());
|
||||||
|
return Sampler.parentBased(rootSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@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
|
@ParameterizedTest
|
||||||
@ValueSource(strings = { "io.micrometer.tracing.otel", "io.opentelemetry.sdk", "io.opentelemetry.api" })
|
@ValueSource(strings = { "io.micrometer.tracing.otel", "io.opentelemetry.sdk", "io.opentelemetry.api" })
|
||||||
void shouldNotSupplyBeansIfDependencyIsMissing(String packageName) {
|
void shouldNotSupplyBeansIfDependencyIsMissing(String packageName) {
|
||||||
|
Loading…
Reference in New Issue
Block a user