opentelemetry-java-contrib/jfr-connection
renovate[bot] aeade81452
fix(deps): update dependency com.google.errorprone:error_prone_core to v2.37.0 (#1805)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
2025-03-21 15:32:41 -07:00
..
src fix(deps): update dependency com.google.errorprone:error_prone_core to v2.37.0 (#1805) 2025-03-21 15:32:41 -07:00
README.md add module jfr-connection (#767) 2023-04-07 07:51:17 -07:00
build.gradle.kts jfr-connection: fixes for using diagnostic command to start a recording (#1352) 2024-07-11 08:52:57 -07:00

README.md

JFR Connection

The jfr-connection module provides a core library for configuring, starting, stopping, and reading Java Flight Recording files from a JVM. The code does not depend on the jdk.jfr module and will compile and run against JDK 8 or higher. It uses a connection to an MBean server, which can be the platform MBean server, or a remote MBean server connected by means of JMX.

  • Java 8+
  • Build with ./gradlew :jfr-connection:build

The main entry point is io.opentelemetry.contrib.jfr.connection.FlightRecorderConnection:

  // The MBeanServerConnection can be local or remote
  MBeanServerConnection mBeanServer = ManagementFactory.getPlatformMBeanServer();

  FlightRecorderConnection flightRecorderConnection = FlightRecorderConnection.connect(mBeanServer);
  RecordingOptions recordingOptions = new RecordingOptions.Builder().disk("true").build();
  RecordingConfiguration recordingConfiguration = RecordingConfiguration.PROFILE_CONFIGURATION;

  try (Recording recording = flightRecorderConnection.newRecording(recordingOptions, recordingConfiguration)) {
      recording.start();
      TimeUnit.SECONDS.sleep(10);
      recording.stop();

      recording.dump(Paths.get(System.getProperty("user.dir"), "recording.jfr").toString());
  }

Note on Oracle JDK 8:

For Oracle JDK 8, it may be necessary to unlock the Java Flight Recorder commercial feature with the JVM arg -XX:+UnlockCommercialFeatures -XX:+FlightRecorder. Starting with JDK 8u262, Java Flight Recorder is available for all OpenJDK distributions.


Component owners

Learn more about component owners in component_owners.yml.