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

Fix Servlet instrumentation for servlet-api 3.1+ - remove output stream wrapper #1167

Conversation

mateuszrzeszutek
Copy link
Member

Fixes #1083

The third time's the charm, I hope. This PR contains removal of the ServletoutputStream wrapper according to this comment.

This might be not so bad anyway, because according to ServletResponse#getOutputStream() JavaDoc:

     * Either this method or {@link #getWriter} may 
     * be called to write the body, not both.

so only those implementations that use getOutputStream() will get inaccurate content sizes (always 0), while those using getWriter() will be perfectly fine.

@mateuszrzeszutek mateuszrzeszutek force-pushed the servlet-3.1-remove-output-stream-wrapper branch 2 times, most recently from cd90a0b to 9386e20 Compare September 4, 2020 11:43
@FrankSpitulski
Copy link
Contributor

Can you add a unit test that succeeds now but if the wrapped response were to be used would fail so that there will be no regressions?

@mateuszrzeszutek
Copy link
Member Author

Can you add a unit test that succeeds now but if the wrapped response were to be used would fail so that there will be no regressions?

I can do a simple instanceof check -- the same way as it was handled in JettyHandlerTest for a similar issue.
Calling either ServletOutputStream#isReady() or ServletOutputStream#setWriteListener() would be ideal, but unfortunately I cannot do that without bumping servlet api version.

@iNikem
Copy link
Contributor

iNikem commented Sep 9, 2020

Taking into account #1096 (comment) and #1083 (comment) I propose to completely remove generic response counting support from servlet instrumentation. I feel bad about this, but if we are left with a partial solution (as @FrankSpitulski noticed above "it misses spring boot's default configuration"), then added complexity is not worth it. History has shown, that this is not as easy as we would like :(

Unless somebody has a good proposal how to solve this otherwise, I ask @mateuszrzeszutek to remove CountingHttpServletRequest, CountingHttpServletResponse and all related functionality for the time being.

@mateuszrzeszutek mateuszrzeszutek force-pushed the servlet-3.1-remove-output-stream-wrapper branch from 9386e20 to f1b01d9 Compare September 9, 2020 07:13
@mateuszrzeszutek mateuszrzeszutek force-pushed the servlet-3.1-remove-output-stream-wrapper branch from f1b01d9 to 5341441 Compare September 9, 2020 07:17
@mateuszrzeszutek
Copy link
Member Author

OK, I've removed all Counting* classes.

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks @mateuszrzeszutek!

@FrankSpitulski Really sorry about this >< Thanks a lot for the help and giving us the opportunity to think through some of the problems regards to instrumentation here, we may not have noticed that Muzzle needs additional checks related to base-class matching without this exercise so will hopefully get better.

@iNikem iNikem merged commit 79b2ce3 into open-telemetry:master Sep 9, 2020
@mateuszrzeszutek
Copy link
Member Author

we may not have noticed that Muzzle needs additional checks related to base-class matching without this exercise so will hopefully get better.

There's an issue for that now: #1123 . I have an idea how to do implement that, so hopefully this will get done soon and we'll avoid similar issues in the future.

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.

Servlet 3.0 instrumentation does not fully cover 3.1 and 4.0
4 participants