I’m developing a spring boot 3 application that must invoke some remote http services.
Inside the application there is a job executing some business logic.
In the business logic there is also the remote services invocation.
I’m trying to find a way to correlate the different http requests i.e. if the business logic is working on a specific object with an Id 123456
I’d like to set a custom header say x-object-id
, with value 123456
. The business logic does not interact directly with the different feign clients, but it uses some adapter.
In order to achieve this I added the following dependencies:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-micrometer</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
I added a custom baggage field to my configuration
@Bean
BaggageField userIdField() {
return BaggageField.create("baggage1");
}
I wrote a test with the following line :
try (BaggageInScope scope = this.tracer.createBaggageInScope("baggage1", "value1")) {
where I invoke the business logic, but I do not see any header baggage1 sent by the feing client.
Can anyone tell me what I’m doing wrong? Is using baggage the correct way to inject custom headers in feign?