Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8253506

JFR: Provide means for accessing event metadata for an event stream

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 16
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      jfr

      Description

      Today you can subscribe to events and data is delivered as instances of the jdk.jfr.RecordedEvent class.

      For example:

      EventStream es = .EventStream.openRepository();
      es.onEvent(event -> {
        Instant start = event.getStartTime();
        Instant end = event.getEndTime();
        String type = event.getEventType().getName();
        System.out.println(s + " - " + e + " : " + type);
      });
      es.start();

      This works well in most scenarios, but sometimes you want to know the event type before you actually get an event in the stream. For example, a GUI could display a dialog where users can select the events to filter out, or render an empty table with name of column header taken from the event fields.

      The jdk.jfr.RecorderFile class provides the method readEventTypes() for this, but there is no corresponding method for an EventStream. Most likely the event types would need to be delivered in a handler, i.e onEventType(...), and called when a stream starts and when new event metadata arrives. It is cumbersome to get this information in a handler, since there is not a good way to detect when the last event type arrives, It also happens in a separate thread than the GUI, so it requires coordination/synchronization. Maybe there is a better method?

      It would be possible deliver a list of event types, i.e onEventTypes(List<EventType> types).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              egahlin Erik Gahlin
              Reporter:
              egahlin Erik Gahlin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: