I have the following demo application Spring Boot 3.4.2:
@SpringBootApplication
@RestController
public class BaggageTestApplication {
public static void main(String[] args) {
SpringApplication.run(BaggageTestApplication.class, args);
}
private static final Log LOGGER = LogFactory.getLog(BaggageTestApplication.class);
private final WebClient webClient;
private final Tracer tracer;
public BaggageTestApplication(WebClient webClient, Tracer tracer) {
this.webClient = webClient;
this.tracer = tracer;
}
@RequestMapping("/")
ResponseEntity<Void> home(@RequestHeader Map<String, String> headers) {
headers.forEach((key, value) -> LOGGER.info(key + ": " + value));
return ResponseEntity.ok().build();
}
@EventListener
public void onApplicationEvent(ApplicationReadyEvent event) {
try (BaggageInScope scope = this.tracer.createBaggageInScope("baggage1", "value1")) {
webClient.get()
.retrieve()
.toBodilessEntity()
.block();
}
}
}
@Configuration
class WebclientConfiguration {
@Bean
public WebClient webClient(WebClient.Builder builder) {
return builder.
baseUrl("http://localhost:8080")
.build();
}
}
and application.yml
:
spring:
application:
name: baggage-test
management:
tracing:
sampling:
probability: 1.0
baggage:
remote-fields: baggage1
enabled: true
enabled: true
I expected the new custom header, baggage1
, to be automatically added during the webClient
request, but only the following were available:
accept-encoding: gzip
user-agent: ReactorNetty/1.2.2
host: localhost:8080
accept: */*
traceparent: 00-67b20fe3ed21c20685f6746f77ef8e74-85f6746f77ef8e74-01
content-length: 0
For some reason, the baggage field wasn't propagated at all.