Original install method (e.g. download page, yum, deb, from source, etc.) and version: Download page
Fresh install or upgraded from other version?: Fresh
Is there anything special in your setup?: Spring boot 2.7.4 application
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
Apm agent doesnt register plain text request body. It does register application/x-www-form-urlencoded.
Using trace logging I can see that the information that the agent sends doesnt include the body.
Debugging with the agent I cant find where the bodyBuffer is assigned with the request data
Steps to reproduce:
Set java option elastic.apm.capture_body=all
Make a POST request with content-type: text/plain
Could anyone refer me to where in the code is the apm request body copied from the servlet request body?
Could you please provide us Debug Logs (via GH gists) of a run from your application which includes both the startup of the application as well as a POST request with content-type text/plain. The debug logs should usually report why a body is not being captured.
Ok, the logs do not indicate any reason why the agent is actively not capturing the body.
Does your application consume the incoming request body? E.g. does your spring controller have something like a @RequestBody String content parameter?
The agent decides on whether or not to capture the body here. Based on that decision the ServletRequest's getInputStream is wrapped here with a stream which copies the data to the transaction. So if your application does not consume the input stream, no data will be recorded on the transaction.
If you are already debugging yourself with the agent source code, these two code locations might allow you to locate the issue.
To my knowledge, the application doesnt consume the incoming request body. Actually the controller method was a GET and I changed it to a POST to test this.
The first line you mention (request.withBodyBuffer()) gets hit. For the second one, I cant get the debugger to stop there. Where is afterGetInputStream supposed to get called from?
Following the code from onEnterServletService and onExitServletServicehere I cant find where afterGetInputStream gets called
afterGetInputStream is invoked whenever any implementation of ServletRequest.getInputStream is called. This very likely never happens because your application doesn't consume the request body. Making your application consume the body should hopefully fix the issue for you.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.