0

The problem occurs when Spring Integration(spring boot) Application calls Spring boot application for sleuth logging of traceID and spanID from.

URL call --> Facade(written in spring integration,spring boot and supports sleuth)--> Spring boot microservice(Sleuth supported)

Microservice 1 : spring integration Http call

Microservice 2 : spring boot Rest controller

Here is the detail of the logs of both of the microservices.

Microservice 1 calls Microservice 2

Microserice 1 log:

2017-04-18 17:42:31.887[0;39m [32m INFO [CS Facade,ff711e7b275d03a7,b3f14f1a5cf6bd1d,true][0;39m [35m6280[0;39m [2m---[0;39m [2m[

Microservice 2 log :

[2m2017-04-18 17:43:26.133[0;39m [32m INFO [-,32226de675c3a463,32226de675c3a463,false][0;39m [35m14184[0;39m [2m---[0;39m [2m[nio-8083-exec-1][0;39m [36mc.t.cloud.resource.HelloResource

Although, both have same request call , traceID is different. It works perfect when both the application are pure spring boot application and no http spring Integration used.

Microservice 1 Code

<int-http:outbound-gateway id="getAccount"
        url="http://localhost:8083/rest/hello/micro2"
        request-channel="receiveChannel" reply-channel="publishsubscribechannel"
        http-method="GET" expected-response-type="java.lang.String">

</int-http:outbound-gateway>

Microservice 2 code

@GetMapping(value = "/micro2")
public String hello() {

    LOGGER.info("Reached micro2"+accessor.getCurrentSpan());
    return "HelloWorld";
}
Atul
  • 77
  • 3
  • 12

2 Answers2

0

I'm sorry but you formatted the code and wrote the text in such a way that I barely understand what the problem is. If both apps are Spring Boot and everything is working fine? That's not strange cause Sleuth is a Boot based library. That means that it's enough to use Boot and Sleuth registers all the necessary components. In case of a non Spring Boot app you basically have to do all the work yourself. That means pass the tracing headers either via HTTP or messaging.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
  • Apologize, I have updated the question. Yes, if there is no spring integration http outbound call, everything works fine. However, usually in microservices architecture, EAI framework like Spring integration is used at facade level. I could see that header has traceID,spanID and URL information when I logged the channel using channel interceptor but it is not getting passed to the second microservices. I am using spring boot with spring integration for facade microservice. I will do some research on http header. – Atul Apr 18 '17 at 10:12
  • added mapped-request-headers="http_requestUrl,X-B3-TraceId,X-B3-SpanId,X-Span-Name" in http and amqp header. it worked well. thanks. – Atul Apr 21 '17 at 01:34
0

Up to Sleuth 2.1.0, spring-integration won't propagate the X-B3* headers automatically.

https://github.com/spring-cloud/spring-cloud-sleuth/issues/1333 with workaround.

dschulten
  • 2,994
  • 1
  • 27
  • 44