0

We incorporated spring cloud sleuth (1.1.3 RELEASE) in our spring boot 1.x application and had no problems with header propagation over rest.

However we upgraded our application to spring boot 2.0.4 and added cloud sleuth 2.0.1 RELEASE. Now, trace and Span Ids are not propagated over rest calls.

Debug points inside of B3Propagation and TracingClientHttpRequestInterceptor are not being invoked at all.

Has something changed in the newer versions of sleuth or is any additional configuration required for the TracingClientHttpRequestInterceptor?

Any pointers would be greatly appreciated.

Thanks.

user10267174
  • 51
  • 2
  • 6

2 Answers2

2

In your bean you need to inject the interceptor, for example with a RestTemplateBuilder:

@Bean public RestTemplateBuilder clientRestTemplateBuilder(TracingClientHttpRequestInterceptor tracingClientHttpRequestInterceptor) { return new RestTemplateBuilder() .additionalInterceptors(tracingClientHttpRequestInterceptor) .(additional config); }

petronius
  • 451
  • 3
  • 11
  • This doesn't works when x-b3-traceid is passed by upstream micro service MS1. (MS1 -> MS2 -> MS3). If MS1 pass trace to MS2, MS2 doesn't pass the same trace to MS3 (even if MS2 explicitly set trace while calling MS3). MS2 generates the new trace everytime. – Vinayak Dornala Apr 15 '20 at 16:43
0

This was happening because the rest template was not available at the time of hooking the TracingClientHttpRequestInterceptor. (was created much before the injection)

Changing the way the rest template was being injected fixed this issue. Thanks.

user10267174
  • 51
  • 2
  • 6