The logs from a sample run where the process waits at least 10 sec and you don't see the transaction in Kibana would be useful - I'd expect the agent to try to send the data and that seems to fail - if this is the case we'd see this in the log including more details about what's exactly happening there - so if possible please upload such a log, that'd help me to troubleshoot this.
I stand corrected, I thought I had 10 Sec wait but it was 1 sec wait, so once I increased the wait (minimum 2.5 sec), I am seeing transactions showing up and I can see the send data statements getting executed. I am not sure if we can put a 2.5 sec delay in our processes. It will have a direct impact to system performance.
Thanks for the reply @kaushas,
ok, so I think we have an explanation for this, which is that the agent did not have enough time to send the data.
This is a known issue and it's on our radar. First of all here is a GitHub issue that you can follow - we plan to come up with a good solution for this problem long term - but that's not something that helps you now.
What you can do now is to tweak some settings. The agent has the FlushInterval setting - the easiest is to set the environment variable
ELASTIC_APM_FLUSH_INTERVAL and make sure it's visible to your process with the agent. You can set it to either 0 - with that the agent will send data immediately, or to some low value. I'd be careful with this in web application, but if this is a short living batch process that generates 1 transaction with a couple of spans then it's fine to set it to either 0 or to a low value. Keep in mind that this won't mean that the agent holds up the application - so if the app terminates before the agent is able to send the data, then the data won't be sent, so you'll still need to make sure the app does not terminate immediately. But with setting this to 0 you can make sure that the agent immediately starts sending the data. With that 1 sec sounds realistic.
thanks, I will play around with Flush Internal and find the optimal setting that works for us. I am also not seeing any Span data. I can create a new issue, if that is more helpful.
if there is still an issue with this, the troubleshooting would be the same - we could just take a look at the logs - we can do it here, too.
For spans the same apply... those are also queued similarly to transactions.