Skip to content

TagPropagationFinishedSpanHandler not auto-configured with yml #1417

@dlsrb6342

Description

@dlsrb6342

Bug report

SleuthTagPropagationAutoConfiguration cannot auto-configured with yaml.
TagPropagationFinishedSpanHandler Bean is conditional on spring.sleuth.propagation.tag.whitelisted-keys

@Bean
@ConditionalOnProperty("spring.sleuth.propagation.tag.whitelisted-keys")
public FinishedSpanHandler finishedSpanHandler(SleuthProperties sleuthProperties,
SleuthTagPropagationProperties tagPropagationProperties) {
return new TagPropagationFinishedSpanHandler(sleuthProperties,
tagPropagationProperties);
}

If you use properties file not yml, it works well. In TagPropagationFinishedSpanHandlerTest.java, it use properties. So it could be passed I think.

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = {
"spring.sleuth.baggage-keys=my-baggage",
"spring.sleuth.propagation-keys=my-propagation,others-propagation",
"spring.sleuth.propagation.tag.whitelisted-keys=my-baggage,my-propagation" },
classes = TagPropagationFinishedSpanHandlerTest.TestConfiguration.class)
public class TagPropagationFinishedSpanHandlerTest {

But if you use yml file, Condition cannot be matched with yml list syntax.

spring.sleuth.propagation.tag.whitelisted-keys: [foo, bar]

spring.sleuth.propagation.tag.whitelisted-keys: 
  - foo
  - bar

All above two cases doesn't work.

ConditionalOnProperty annotation cannot be used with Collections. Please check below javadoc link.
https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.html

I think it have to apply custom Conditional annotation for colleciton. Or just make bean when spring.sleuth.propagation.tag.enabled is true.

FYI, If you want to use TagPropagationFinishedSpanHandler with yml file, Only spring.sleuth.propagation.tag.whitelisted-keys: foo,bar works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions