I'm trying to integrate Sleuth into our system. If I use interfaces annotated with @FeignClient
, everything works fine. These interfaces get instrumented automatically, and Sleuth headers get propagated with REST calls.
But, we have some existing code that uses Feign.Builder directly with Feign annotated interfaces (just not annotated with @FeignClient
). This code adds some custom request interceptors, encoder, proxy, etc.
For example:
// Feign REST interface
public interface MyService {
@RequestMapping(method = RequestMethod.GET, value = "/version")
String getVersion();
}
// Creating the builder
Feign.Builder builder = Feign.builder();
builder.requestInterceptor(new MyCustomInterceptor());
// + adding proxy, encoder, decoder, etc
// Using the builder
MyService myService = builder.target(MyService.class, "http://localhost:8080/myservice");
myService.getVersion();
I would like this older code to propagate Sleuth headers. Is there some easy way to wire this up?
(I suppose one option is to rework our Feign interfaces to have @FeignClient and rework how all of the custom interceptors, encoders, etc get applied, but ultimately that might be a lot of work with a lot of risk.)
Do I need to do a special request interceptor to inject these manually (e.g. from an autowired Tracer)? Is there a clean way (or existing class) to do that?