• Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 14, 16
    • Fix Version/s: 16
    • Component/s: hotspot
    • Subcomponent:


      JEP 349: JFR: Event Streaming added support for streaming recordings from disk. This works well in situations where the client is on the same the machine, but not when you want to monitor a remote Java process.

      JMX already today provide monitoring capabilities using MBeans and JFR provides the FlightRecorderMXBean which allows stopped recordings to be downloaded. Plan is to allow data from ongoing recordings to also be read over the network.

      For tools and monitoring frameworks that already rely on JMX today, it would be convenient if there was a class (RemoteRecordingStream) that would allow them to continuously consume JFR data using a MBeanServerConnection.

      Example usage:

      public void monitorExceptions(MBeanServerConnection conn, Path temp) {
        try (var rs = new RemoteRecordingStream(conn, temp)) {
           rs.onEvent(e -> {
              String className = e.getClass("thrownClass").getName();
              Instant time = e.getEndTime();
              String message = e.getString("message");
              System.out-println(time + " " + className + " : " + message);
              if (className.equals("java.lang.NullPointerException") {
                 Path p = Paths.get("dump.jfr").getAbsolutePath();
                 System.out.println ("NullPointerException detected!");
                 System.out-println("See dump at " + p);
          System.out-println("Exception Log");

      The RemoteRecordingStream implements the jdk.jfr.consumer.EventStream that already exists today. This means that a local or remote stream can easily be changed. Even if users don't want to listen on events as they happen, this mechanism will allow users to replicate the repository to a different host.


          Issue Links



              • Assignee:
                egahlin Erik Gahlin
                egahlin Erik Gahlin
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: