API control over snapshot directory

Questions about YourKit Java Profiler
Locked
faceless
Posts: 2
Joined: Sun Mar 21, 2021 3:57 pm

API control over snapshot directory

Post by faceless »

Long time user of Yourkit - I'm investigating integrating Yourkit with my Jenkins CI server, the goal being automatically sampling the test runs of our application, and storing the output so I can check for change over time.

I've come to the conclusion the best way to do this, for us, is to use the API. We use ant, which compiles the source then runs our regression test in the same JVM. I don't want to profile the build stage. I also don't want to profile the regression analysis at the end. So

The API looks easy to use, except that I can't seem to set the directory I want the snapshot written to. This matters - I want to archive the snapshot along with the rest of the output, so I need to make sure it's in the correct place. And I'd rather not use the "<agent user home>/.yjp/snapshotdir.txt" approach - there may be multiple tests running at once, so I don't want a static configuration file.

Is there any way to set the directory programatically? If not is this something that could be added? controller.setSnapshotDirectory() or something would be ideal.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: API control over snapshot directory

Post by Anton Katilin »

Hello,

Snapshot directory customization is described in https://www.yourkit.com/docs/java/help/snapshot_dir.jsp

You can set the directory per process by using the "dir" agent startup option:
https://www.yourkit.com/docs/java/help/ ... ns.jsp#dir

There is no API call to change the snapshot directory. However, you can move the snapshot file to another location programmatically right after capturing the snapshot. The methods Controller.capture*Snapshot() return the captured snapshot file path, please use java.nio.file.Files.move() to move the file to the desired location.
faceless
Posts: 2
Joined: Sun Mar 21, 2021 3:57 pm

Re: API control over snapshot directory

Post by faceless »

Thanks Anton, using Files.move() was the conclusion we came to as well.
Locked