Skip to content

Conversation

@thugrock7
Copy link
Contributor

No description provided.


if (!request.isAsyncStarted()) {
if (instrumentationConfig.httpHeaders().response()) {
httpResponse.flushBuffer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HttpServletResponse getHeaderNames() will only give headers that are set via set/add Headers functions at client side (docs), so for servlet applications where content-type is set in general with setContentType(), at this specific point if we call getHeaderNames(), it will not contain content-type, content-length etc headers as it is explicitly not set by setHeader()/addHeader() at client side. So we will not collect the content-type header and thereby dropping the body. (For context look at the simple application here)

The info which is set by setContentType(), setContentEncoding() etc are available in buffer, which will be set as headers to client at close commit normally, so calling flushbuffer() ourselves on OnMethodExit() before to get these headers populated into span.

@thugrock7 thugrock7 merged commit 974191e into hypertrace:main Jan 2, 2025
9 checks passed
@thugrock7 thugrock7 deleted the servlet-5.0-body-fix branch January 2, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants