nipwaayoni / elastic-apm-php-agent

PHP Agent for Elastic APM
Other
28 stars 15 forks source link

Memory exhausted on putEvent #83

Open tomvo opened 1 year ago

tomvo commented 1 year ago

I'm getting sometimes a memory exhausted exception on the following location: /vendor/nipwaayoni/elastic-apm-php-agent/src/Middleware/Connector.php@putEvent()

I assume it has to do with encoding the payload for an exception or another trace that is too large. Is there a way to limit large payloads being trying to be sent to APM?

dstepe commented 1 year ago

If an excessively large stack trace is the culprit, you might be able to use the stack-trace-limit option to mitigate it. If it's an exception content or something else, then no, there is no overall control of the content size.

Memory configuration is implementation specific, and efficient memory usage is up to the application. Have you considered increasing the memory for the PHP process? Or could accumulated large objects/data structures in the application contribute to this?

tomvo commented 1 year ago

thanks for replying Dirk. I looked further into this and it does seem to occur on locations where we are handling large amounts of data. It's internal RPC calls with a lot of bulk elasticsearch data. I guess the stack-trace-limit option might not mitigate this. However i'm wondering why we're seeing an Exception in the APM library since i don't see any exceptions being triggered that is causing a log to APM.

dstepe commented 1 year ago

How are you using this package? In most cases, APM collects more than exceptions. I would expect there to be transactions sent to APM regardless of any exceptions. I would not be surprised that your process runs fine, collecting transactions with potentially lots of spans and metadata, then passes it all to the agent to send to APM.