Issue
As per the README here , I am using the following configuration to pass x-vcap-request-id
and x-vcap-group-id
from one application to the other.
@Bean
public Factory propagationFactory() {
return brave.propagation.ExtraFieldPropagation.newFactory(brave.propagation.B3Propagation.FACTORY,
"x-vcap-request-id", "x-vcap-group-id");
}
@Bean
public TracingFactoryBean tracing() {
TracingFactoryBean tracingFactoryBean = new TracingFactoryBean();
tracingFactoryBean.setPropagationFactory(propagationFactory());
return tracingFactoryBean;
}
However, this configuration is messing up default sleuth behavior. With this code, Sleuth no longer adds TraceId
and SpanId
to the log
What's the best/recommended way to pass along custom headers between microservices ?
Solution
If you read the docs on prefixed fields you'll see the following section
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.
Just set the properties and things will work out of the box. It's always good to read the project documentation.
Answered By - Marcin Grzejszczak
Answer Checked By - Senaida (JavaFixing Volunteer)