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

feat: servlet 5.0 body capture fix #411

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thugrock7
Copy link
Contributor

No description provided.

@@ -187,6 +187,7 @@ public static void exit(

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.

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