Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change X-Trace-Id response header in favour of "traceresponse" #44431

Open
bclozel opened this issue Feb 25, 2025 · 7 comments
Open

Change X-Trace-Id response header in favour of "traceresponse" #44431

bclozel opened this issue Feb 25, 2025 · 7 comments
Assignees
Labels
status: on-hold We can't start working on this issue yet type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Feb 25, 2025

We received feedback on our new X-Trace-Id response header support for Spring Boot 3.5 (see #40857). Instead of using an X- header we could be considering one of the currently developed drafts.

It seems both traceresponse and Server-Timing are being considered at the moment, with no clear guidance from the observability community. As far as I understand, Server-Timing has the following priorities:

This specification enables a server to communicate performance metrics about the request-response cycle to the user agent. It also standardizes a JavaScript interface to enable applications to collect, process, and act on these metrics to optimize application delivery.

Browsers can use this header to include its information in their "Developer tools" tabs to give the full picture of the web page performance: from backend activity to resource loading and HTML rendering. The traceId information would only be useful if this UI is also capable of retrieving and rendering the full trace information in the same context.

I think we'll go with the traceresponse header and the related format, as its main goal is to identify a completed request in a tracing system, which better aligns with our intent here.

@bclozel bclozel added the type: enhancement A general enhancement label Feb 25, 2025
@bclozel bclozel added this to the 3.5.0-M3 milestone Feb 25, 2025
@bclozel bclozel self-assigned this Feb 25, 2025
@bclozel bclozel added the status: pending-design-work Needs design work before any code can be developed label Feb 25, 2025
@kzander91
Copy link
Contributor

@bclozel Wouldn't it make sense make the header name configurable? Additionally, is there a reason for not supporting this for WebFlux?

@bclozel
Copy link
Member Author

bclozel commented Feb 26, 2025

Wouldn't it make sense make the header name configurable?

I'm not sure I understand; how would that work?

Additionally, is there a reason for not supporting this for WebFlux?

No, I'm working on it. We were just waiting for community feedback before expanding support.

@kzander91
Copy link
Contributor

kzander91 commented Feb 26, 2025

I'm not sure I understand; how would that work?

Instead of using this constant here:


The filter gets a bean property traceIdHeaderName that is being populated by ObservationFilterConfigurations from a new property, something like management.observations.http.server.requests.trace-header-name=x-my-custom-trace-id-header-name.

We were just waiting for community feedback before expanding support.

I see, thank you.

@bclozel
Copy link
Member Author

bclozel commented Feb 26, 2025

@kzander91 but what would be the purpose of changing the header name? X-Trace-Id, traceresponse and Server-Timing all have different formats for the header value. What would be the goal?

@kzander91
Copy link
Contributor

Sorry, I missed that we're not just discussing header names, but also different header values (i.e. formats). I guess if we're using established header names, it would not make sense to make them customizable, you're right.

In my app, I have built a filter myself that exposes the trace id as a response header (under a name I have chosen myself). If this topic was just about exposing the trace id, and the header name was configurable, I could have replaced my own filter with Boot's new filter.

@bclozel
Copy link
Member Author

bclozel commented Feb 27, 2025

No worries @kzander91 I was just making sure I didn't miss anything.

As for the custom header that was our original intent but we got feedback and apparently that's not what people expect. Hopefully the "traceresponse" will be more adopted in the future.

bclozel added a commit to bclozel/spring-boot that referenced this issue Feb 27, 2025
Prior to this commit, we added support for the "X-Trace-Id" HTTP
response header in spring-projectsgh-40857. This wrote the traceId information for MVC
applications, if the `management.observations.http.server.requests.write-trace-header`
was set.

After receiving feedback from the community, we are revisiting this
feature with the following changes:

* the header is now "traceresponse" and implements the W3C draft
  standard, see https://w3c.github.io/trace-context/#trace-context-http-response-headers-format
* the property is now
  "management.observations.http.server.requests.write-traceresponse"
* both MVC and WebFlux are now supported

Closes spring-projectsgh-44431
@bclozel
Copy link
Member Author

bclozel commented Feb 27, 2025

Changes are now ready but on hold, as we are discussing with the Micrometer team whether this feature belongs in Micrometer directly.

@bclozel bclozel added status: on-hold We can't start working on this issue yet and removed status: pending-design-work Needs design work before any code can be developed labels Feb 27, 2025
@bclozel bclozel modified the milestones: 3.5.0-M3, 3.5.x Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: on-hold We can't start working on this issue yet type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants