Hi I'm just curious if the APM libraries can be used for short lived jobs (ie. a cron job that processes some entries in a queue and puts them in a database and exits). I haven't seen any special configuration for this. Do the APM libs flush before exit automatically or are they more suited for long-running daemons?
Excellent question! It depends a bit on which agent/language you use. Some agents, e.g. for Java and Python, will automatically flush the queue before the process exits (assuming a clean shutdown of the process). For other agents, like .net and Go, you will have to use the available APIs to manually flush the queue at the end of your program.
Hey thanks for the response. Can you point me to any documentation where the manual flush is described, and which languages require it? Based on what you're saying it sounds like even the daemon processes should flush prior to shutdown.
So, for Go, here is the Flush function with some documentation.
Also, here you can read a little bit more about this topic.
For .NET we don’t really have a public API yet to flush data manually, so the use case is not really supported at the moment in .NET. In .NET we have some settings that can help in this case, but those don’t really solve the problem.
Is there any specific language where we should follow up with more details?
Hey thanks @GregKalapos. I'm doing a survey for a deployment involving several languages so I'm trying to see how much difference there is between agents. Currently researching go and ruby.
From what I can see with the ruby agent, the worker (short lived jobs) does a flush before shutdown, but the rails server does not?
And the go agent lib requires an explicit flush before exit in both worker and server applications.
Node.js tries to flush on process exit, but the process could be in an unknown or unexpected state at that point so there's no guarantees it would actually succeed.
The Ruby agent should empty its queue before exiting but there are no guarantees. The agent behaves the same with Rails request events as with events from background jobs. The Worker in the agent codebase is only related to the inner workings of the agent and doesn't relate directly to the concept of your app's worker processes.
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.