1
votes

I have 2 spring boot microservice using Spring Cloud Stream and Kafka Binder. I am using Spring cloud sleuth dependencies for log tracing. In microservice A, while publishing an event to a topic in kafka, I am setting trackId as

ExtraFieldPropagation.set("trackId","valueHeader");

I am not getting this value as baggage header in microservice B. I am getting TraceId, SpanID but not the baggage element I setting as above.

1

1 Answers

3
votes

Have you read the documentation under this section? https://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#_prefixed_fields

A difference from previous versions of Sleuth is that, with Brave, you must pass the list of baggage keys. There are two properties to achieve this. With the spring.sleuth.baggage-keys, you set keys that get prefixed with baggage- for HTTP calls and baggage_ for messaging. You can also use the spring.sleuth.propagation-keys property to pass a list of prefixed keys that are whitelisted without any prefix.

Have you explicitly provided the baggage keys? E.g. https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service1/src/main/resources/application.yaml#L9-L11

spring:
  sleuth:
    # you have to explicitly provide baggage keys
    baggage-keys:
      - trackId
      - valueHeader