In my @SpringBootTest annotated tests it won't load the BraveAutoConfiguration automatically as it says that there is a different value in the property 'enabled'
BraveAutoConfiguration:
Did not match:
- @ConditionalOnProperty (management.tracing.enabled) found different value in property 'enabled' (OnPropertyCondition)
Matched:
- @ConditionalOnClass found required classes 'brave.Tracer', 'io.micrometer.tracing.brave.bridge.BraveTracer' (OnClassCondition)
But in my application.yml in my test resources I have management.tracing.enabled set to true. (it is true by default but that doesn't seem to matter)
spring:
profiles:
active: test
debug: true
management:
tracing:
enabled: true
When I start my application it does find the BraveAutoConfiguration and the application.yml has the same property set to true.
My test is annotated with the following annotations
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration
@AutoConfigureMockMvc
Comment From: bclozel
Do you have a sample application we can take a look at?
Comment From: sbrannen
But in my application.yml in my test resources I have management.tracing.enabled set to true. (it is true by default but that doesn't seem to matter)
Wouldn't that file need to be named application-test.yml -- since you're activating the "test" profile?
Or do you perhaps have a "test" profile section in your main application YAML?
Comment From: plebcity
Or do you perhaps have a "test" profile section in your main application YAML?
I have spring.profiles.active: test in my application.yml.
Comment From: plebcity
Do you have a sample application we can take a look at?
I can make one but it is as easy as going to start.spring.io and including the distributed tracing dependency. When you enable debug you will see that BraveAutoConfiguration is not loaded in the test but it is loaded in the application.
I've made a demo project anyway: https://github.com/plebcity/spring-boot-conditional-bug-29616
Comment From: mhalbritter
If you want to have tracing in your integration tests, you need to use @AutoConfigureObservability as documented here.
Comment From: plebcity
If you want to have tracing in your integration tests, you need to use
@AutoConfigureObservabilityas documented here.
Thanks, it's working now.