I've been migrating from Spring Boot 2.6 and ran into an issue where brave.propagation.CurrentTraceContext can be injected in runtime but fails in tests.
package com.example.braveautoconftestproblem;
import brave.propagation.CurrentTraceContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BraveAutoconfTestProblemApplication {
public BraveAutoconfTestProblemApplication(CurrentTraceContext currentTraceContext) {
System.out.println(currentTraceContext);
}
public static void main(String[] args) {
SpringApplication.run(BraveAutoconfTestProblemApplication.class, args);
}
}
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'braveAutoconfTestProblemApplication': Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'brave.propagation.CurrentTraceContext' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'brave.propagation.CurrentTraceContext' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Minimal project in attachment: brave-autoconf-test-problem.zip
When started with debug=true it doesn't even process BraveAutoConfiguration.
I looked at migration guide but didn't find anything related to testing.
Comment From: wilkinsona
This is by design. As described in the documentation, you need to use @AutoConfigureObservability to enable tracing in a @SpringBootTest.