diff --git a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java index 7d1973dd..a180c35e 100644 --- a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java +++ b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java @@ -148,6 +148,40 @@ public void testDefaultNewGCMetricsUseGenerationalZGC() throws IOException { } } + @Test + public void testDefaultNewGCMetricsIBMJ9Balanced() throws IOException { + try (final MisbehavingJMXServer server = new MisbehavingJMXServer.Builder().withJDKImage( + JDK_11_OPENJ9).appendJavaOpts("-Xgcpolicy:balanced").build()) { + final List> actualMetrics = startAndGetMetrics(server, true); + assertThat(actualMetrics, hasSize(13)); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_count", "partial gc", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_time", "partial gc", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_count", "global garbage collect", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_time", "global garbage collect", "counter"); + } + } + + @Test + public void testDefaultNewGCMetricsIBMJ9Gencon() throws IOException { + try (final MisbehavingJMXServer server = new MisbehavingJMXServer.Builder().withJDKImage( + JDK_11_OPENJ9).appendJavaOpts("-Xgcpolicy:gencon").build()) { + final List> actualMetrics = startAndGetMetrics(server, true); + assertThat(actualMetrics, hasSize(13)); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_count", "scavenge", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_time", "scavenge", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_count", "global", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_time", "global", "counter"); + } + } + private List> startAndGetMetrics(final MisbehavingJMXServer server, final boolean newGCMetrics) throws IOException { server.start(); diff --git a/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java b/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java index 365f7bd5..19775b77 100644 --- a/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java +++ b/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java @@ -4,7 +4,8 @@ public enum JDKImage { BASE("base"), JDK_11("eclipse-temurin:11"), JDK_17("eclipse-temurin:17"), - JDK_21("eclipse-temurin:21"); + JDK_21("eclipse-temurin:21"), + JDK_11_OPENJ9("adoptopenjdk/openjdk11-openj9:latest"); private final String image;