Home > Enterprise >  Java Flight Recorder: Recording data as a byte array
Java Flight Recorder: Recording data as a byte array

Time:10-16

Recording allows to save recorded data into file using dump() method (as shown in example below copied from the javadoc). Is there a way how to get such recorded data in form of byte[].

Preferably without external dependencies. I'm aware of implementing custom in-memory FileSystem.

   Configuration c = Configuration.getConfiguration("default");
   Recording r = new Recording(c);
   r.start();
   System.gc();
   Thread.sleep(5000);
   r.stop();
   r.dump(Files.createTempFile("my-recording", ".jfr"));

CodePudding user response:

Are you looking for getStream? That's the only API on Recording that might possibly suggest a way to do it. Other than that, you'll pretty much have to use dump to a Path, either to an in-memory filesystem or maybe even to an actual temporary file.

  • Related