spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Micrometer tracing propagation not working when using Spring FactoryBean and Feign

Open raul-avila-ph opened this issue 5 months ago • 1 comments

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:

  1. Have Micrometer tracing enabled
  2. Configure a Feign client
  3. Create a service class that contains the Feign client as dependency
  4. 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.

raul-avila-ph avatar Mar 27 '24 15:03 raul-avila-ph