即使在Bluemix中作为标题传递给服务请求,侦听标头X-B3-TraceId值也会重新生成

时间:2018-01-11 02:10:06

标签: java spring ibm-cloud spring-cloud-sleuth

我希望我的服务使用者将TraceId作为Header Param传递,名称为X-B3-TraceId,并且有效的128位十六进制字符串将在另一条路径中传播,实际上服务会将相同的侦听跟踪ID返回给调用者。我已经使用Spring Cloud Sleuth添加了Custom Filter和Span Extractor以便进入Service Response。

当在嵌入式tomcat中部署App时,整个设置在我的本地运行良好,但是当在Bluemix中部署相同的App时,响应没有在请求中传递的相同的侦听跟踪ID。

在IBM Bluemix Cloud Foundry中使用Sleuth时,是否存在任何已知此类问题的缺陷和解决方法?

如果是,请告知如何继续。

我在以下位置创建了演示项目:https://github.com/imram/sleuthHeaderIssue

Please Run the Micro Service locally.    
URL: localhost:9090/hello?name=Ram
Header:
    X-B3-TraceId:d61436368bae3c12ce5f844337f3ee52

Service will return:
    HELLORam
    Header:
    Content-Length →8
    Content-Type →text/plain;charset=UTF-8
    Date →Thu, 11 Jan 2018 01:38:48 GMT
    X-Application-Context →application:9090
    X-B3-TraceId →d61436368bae3c12ce5f844337f3ee52

    Note Trace Id is same in RQ and RS.

Deploy Same Service in IBM Bluemix:
    URL: https://sleuth-header-demo.mybluemix.net/hello?name=Ram .
    Header
    X-B3-TraceId:d61436368bae3c12ce5f844337f3ee52

    Response:
       HELLORam
       Header:
       Connection →Keep-Alive
       Content-Type →text/plain;charset=UTF-8
       Date →Thu, 11 Jan 2018 01:38:30 GMT
       Transfer-Encoding →chunked
       X-Application-Context →sleuth-header-demo:bluemix:0
       X-B3-Traceid →b896d05d9f0ae105
       X-Backside-Transport →OK OK
       X-Global-Transaction-ID →2714561407

 See the Trace Id(X-B3-Traceid) got ignore what was present in 
 Request and got Regenerated as b896d05d9f0ae105

1 个答案:

答案 0 :(得分:0)

您始终需要传递跟踪标头。必须传播所有X-B3标头,以使分布式跟踪正常工作。