spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.41k stars 40.51k forks source link

Write TraceId in HTTP Response headers #40857

Open bclozel opened 3 months ago

bclozel commented 3 months ago

As of https://github.com/spring-projects/spring-framework/issues/30632, Spring Framework allows to extend the ServerHttpObservationFilter. Spring Boot could extend this class and contribute it if "micrometer-tracing" is on the classpath and a Tracer bean is available.

The sample implementation is quite straightforward. We should then adapt the auto-configuration to only contribute this filter subclass if conditions are meant, otherwise keep contributing the current setup.

neiser commented 3 months ago

@bclozel Thanks for pushing this forward. Adding a TraceId Response Header is something I usually configure by hand and it would be nice if that was something provided by Spring Boot out-of-the-box! Just a bit more Spring Boot magic, which is great IMHO. I can't promise much, but would you accept a Pull Request for this issue?

bclozel commented 3 months ago

@neiser thanks for the offer - Spring Boot 3.4 is due next November and the main branch is not currently building against Spring Framework 6.2 so I don't think we're in a position to work on this right now.