elastic / apm-agent-php

Apache License 2.0
253 stars 69 forks source link

Don't send each segment in an isolated request #991

Open julien-maurel opened 1 year ago

julien-maurel commented 1 year ago

Is your feature request related to a problem? Please describe. When transactions have a lot of spans, cpu usage (on apm agent) and network connections (on website and on agent) increase enormously due to number of http request

Describe the solution you'd like After checking code of tracer, everything is done to be able to send multiple segments in a single http request, but today each segment is sent on ending Have on option to be able to send data of a transaction in a single request limit consumption of cpu/network

Additional context I tested a quick and dirty solution (add spans/errors on a property of tracer and send content of this property when a transaction is send). It's not a good implementation but like this I can check difference

Data :

CPU usage of apm agent : image I don't have graph about network, but I can see impact on external service calls, there was a lot of timeout / increase latency during test between 14h and 14h10

SergeyKleyman commented 1 year ago

@julien-maurel Thank for opening this issue. Could you please clarify which version of the agent do you use? The reason I am asking is because in 1.8.1 an improvement to communication was implemented (after the improvement agent does not close the connection after each request with data sent to APM Server). In case you use a version before 1.8.1 could you please try the latest version (which is 1.8.4 at the moment)?

julien-maurel commented 1 year ago

@SergeyKleyman i'm using last version (1.8.4)