springspring-cloud-sleuth

Renaming x-b3-traceid header in spring cloud


I'm trying to configure Spring sleuth 2.0.3.RELEASE to propagate trace ids through my service calls. By default it sends x-b3-traceid header in the request, but i'm unable to rename the header to say, x-request-id instead. Is there any out-of-the-box method, or preferred method to achieve this?


Solution

  • Don't rename it but add another one that will be propagated. You can read about this in brave docs https://github.com/apache/incubator-zipkin-brave/blob/master/brave/README.md#propagating-extra-fields

    However in Sleuth you don't have to run those methods. It's enough for you to set a property

    spring.sleuth.propagation-keys=yourHeaderName
    

    You can read about it here https://cloud.spring.io/spring-cloud-static/Greenwich.SR1/single/spring-cloud.html#prefixed-fields