Is it possible to get the currently executing test worker process in a TestListener?


I’m looking to collect jvm metrics of the current worker jvm process executing a test. We have a lot of tests which push the limits of the gradle workers and it would be nice to be able to link those metrics to the currently executing test. How many threads? Heap size? What is the GC doing etc.

I was thinking whether a test listener would be an approach? Would it be possible to find the current worker process id from there?

Or what would be a recommended approach?