Is it possible / advisable to use APM in my scenario?

Hello

I've got a Java desktop application which does not rely on any external server - the application can run independently on each users individual machine. (Think of an application like notepad)

I'd like to gather crash data & stack traces from the users of my app.

I've installed an elastic stack on a server & I attached an apm agent to my local debug snapshot of my application, and this successfully gathers and displays my crash-data in my kibana dashboard for my local debug build.

Is there a good way of including the apm-agent on each user installation?

In my developer-snapshot, I'm including the apm-agent.jar using the run param:
-J-javaagent: c:/path/to/apm-agent.jar
However, this makes the application not start if the apm agent isn't found, and ensuring the apm-agent.jar is included in all user installations in a specific folder feels a little unstable, making me wonder if there's another solution I'm supposed to be using?

Thanks in advance for any help & advice.

This installation method would probably be better suited for your use case: https://www.elastic.co/guide/en/apm/agent/java/current/setup-attach-api.html

Thanks for the reply - yes, this direction looks more promising, unfortunately the application uses OSGi containers, which does not seem to be supported with this method. Is there a way around this?

Indeed, with this method OSGi is not expected to work properly. If you find a configuration option provided by your OSGi framework that lets you define packages you want it to delegate for loading by the application class loader, you may try it out with our base package co.elastic.apm.agent.*.

However, it's best if you find a way to use -javaagent. If your application is started with a script or a Windows process, you will need to provide a new version of your app, so why can't you make sure that it is appending the -javaagent directive to the command line ONLY if the agent jar is bundled?