简体   繁体   English

Sleuth Header X-B3-TraceId 值会重新生成,即使作为 Bluemix 中的标头传递给服务请求

[英]Sleuth Header X-B3-TraceId value get Regenerated even if passed to the Service Request as Header In Bluemix

I would like my service consumers pass the TraceId as Header Param with name X-B3-TraceId and valid 128 bits Hex String that shall get propagated in further path down the line and indeed service will return same Sleuth Trace Id back to caller.我希望我的服务消费者将 TraceId 作为标题参数传递,名称为 X-B3-TraceId 和有效的 128 位十六进制字符串,这些字符串将在线路的进一步路径中传播,实际上服务会将相同的 Sleuth Trace Id 返回给调用者。 I have used Spring Cloud Sleuth added Custom Filter and Span Extractor in order to put in in Service Response.我使用 Spring Cloud Sleuth 添加了自定义过滤器和跨度提取器,以便放入服务响应。

The Entire set up works well in my local when App is deployed in Embedded tomcat, however when same App is deployed in Bluemix then The Response does not have same Sleuth Trace Id which was passed in Request.当应用程序部署在嵌入式 tomcat 中时,整个设置在我的本地运行良好,但是当相同的应用程序部署在 Bluemix 中时,响应没有在请求中传递的相同 Sleuth Trace Id。

Is there any known such defect and workaround for this problem when Sleuth is used in IBM Bluemix Cloud Foundry ?在 IBM Bluemix Cloud Foundry 中使用 Sleuth 时,是否有任何已知的此类缺陷和解决方法?

If it is, could you please advise how to proceed.如果是,请您建议如何进行。

I have created Demo Project in following location: https://github.com/imram/sleuthHeaderIssue我在以下位置创建了演示项目: 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

You always need to pass tracing headers. 您始终需要传递跟踪标头。 All the X-B3 headers must be propagated to make distributed tracing work properly. 必须传播所有X-B3标头,以使分布式跟踪正常工作。

below 2 conditions are required:需要以下2个条件:

  1. both X-B3-TraceId and X-B3-SpanId are required in header标头中需要 X-B3-TraceId 和 X-B3-SpanId
  2. the value of X-B3 variables should be valid. X-B3 变量的值应该是有效的。
    @GetMapping("/async")
    public String helloSleuthAsync() throws InterruptedException {       
        return "success, traceId:" + MDC.get("X-B3-TraceId");
    }

eg例如

condition 2 is matched:条件 2 匹配:

curl --location --request GET 'http://localhost:8080/async' \
--header 'X-B3-TraceId: d61436368bae3c12' \
--header 'X-B3-SpanId: ce5f844337f3ee88'

response: success, traceId:d61436368bae3c12

condition 2 is not matched:条件 2 不匹配:

curl --location --request GET 'http://localhost:8080/async' \
--header 'X-B3-TraceId: marius' \
--header 'X-B3-SpanId: marius'

response:success, traceId:4faae9c09822cf72

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM