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.

Comment From: neiser

@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?

Comment From: bclozel

@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.

Comment From: kesrishubham2510

Hi @bclozel, I'm new to open source and would like to contribute. This can be learning opportunity for me. In one of my learning project (spring-webflux), I used a WebFilter to add the traceId and spanId to my incoming requests.

Please let me know if I can contribute in any way.

Comment From: dalbani

FYI, the wish to have such an X-Trace-Id header was also expressed by users of the OpenTelemetry Java agent: https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions/8175.

I'm curious though why a custom header was chosen, instead of (not yet officially ratified) traceresponse header: - https://github.com/w3c/trace-context/blob/main/spec/21-http_response_header_format.md - https://w3c.github.io/trace-context/#trace-context-http-response-headers-format

Actually, falling into the rabbit hole of traceresponse, I just discovered that there is a suggestion to (also) use the existing Server-Timing header: - https://github.com/w3c/trace-context/issues/556 - https://github.com/open-telemetry/opentelemetry-specification/issues/3811

Comment From: ciscoo

X- prefix is deprecated by RFC 6648 as well, but I don't think much attention is given to it.

Comment From: bclozel

@dalbani nobody requested this format before you did. It's probably a good idea to revisit the header format in the milestone phase. Please create a new issue to request this change.