Prevent ignoring of ExtraFieldCustomizer (#1455)
Changes verification in TraceAutoConfiguration.sleuthPropagation() to not skip customization if at least one ExtraFieldCustomizer is defined. Without this fix the customizers are only applied when either baggage-keys or propagation-keys property is defined. Fixes gh-1454
This commit is contained in:
committed by
Marcin Grzejszczak
parent
29c9afe403
commit
9dbf99c675
@@ -146,7 +146,8 @@ public class TraceAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
Propagation.Factory sleuthPropagation(SleuthProperties sleuthProperties) {
|
||||
if (sleuthProperties.getBaggageKeys().isEmpty()
|
||||
&& sleuthProperties.getPropagationKeys().isEmpty()) {
|
||||
&& sleuthProperties.getPropagationKeys().isEmpty()
|
||||
&& extraFieldCustomizers.isEmpty()) {
|
||||
return B3Propagation.FACTORY;
|
||||
}
|
||||
ExtraFieldPropagation.FactoryBuilder factoryBuilder;
|
||||
|
||||
@@ -36,14 +36,13 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
public class TraceAutoConfigurationCustomizersTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withPropertyValues("spring.sleuth.baggage-keys=my-baggage")
|
||||
.withConfiguration(AutoConfigurations.of(TraceAutoConfiguration.class,
|
||||
TraceWebAutoConfiguration.class, TraceHttpAutoConfiguration.class))
|
||||
.withUserConfiguration(Customizers.class);
|
||||
|
||||
@Test
|
||||
public void should_apply_customizers() {
|
||||
this.contextRunner.run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.sleuth.baggage-keys=my-baggage").run((context) -> {
|
||||
Customizers bean = context.getBean(Customizers.class);
|
||||
|
||||
shouldApplyCustomizations(bean);
|
||||
@@ -51,6 +50,15 @@ public class TraceAutoConfigurationCustomizersTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_apply_extra_field_customizer_when_no_extra_properties_are_defined() {
|
||||
this.contextRunner.run((context) -> {
|
||||
Customizers bean = context.getBean(Customizers.class);
|
||||
|
||||
shouldApplyCustomizations(bean);
|
||||
});
|
||||
}
|
||||
|
||||
private void shouldNotOverrideTheDefaults(AssertableApplicationContext context) {
|
||||
then(context.getBean(Sampler.class)).isSameAs(Sampler.ALWAYS_SAMPLE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user