spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
Micrometer tracing propagation not working when using Spring FactoryBean and Feign
Bug description
We found a problem where Micrometer tracing propagation stops working when a Feign client is injected to a Spring FactoryBean.
Steps to reproduce:
- Have Micrometer tracing enabled
- Configure a Feign client
- Create a service class that contains the Feign client as dependency
- Instantiate the service class through a Spring FactoryBean, not using stereotype annotations or bean declaration. This FactoryBean will need to have a reference to the Feign client, because it will be necessary to instantiate the service class created in step 3
We would expect Micrometer traces to continue working. With the setup explained above it stopped working.
Sample
We have created a small sample project reproducing the issue, it can be found here: https://github.com/raul-avila-ph/tracing-issue/
The project contains a single test that passes only when tracing is working properly. The code in master
has the test failing, while you can see there is a branch called without-factory-bean
that basically removes the FactoryBean and instantiates the service with @Service
. The test in this branch works, so tracing is not broken under these conditions.
Please note that this problem occurs when Feign client is a transitive dependency of the Spring FactoryBean as well, we have just injected it directly in the sample code for simplicity.