Skip to content

Commit 9e7edab

Browse files
authored
Fix OpenJ9 test failure (#13311)
1 parent cb16d45 commit 9e7edab

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

smoke-tests-otel-starter/spring-boot-3/src/test/java/io/opentelemetry/spring/smoketest/OtelSpringStarterSmokeTest.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class OtelSpringStarterSmokeTest extends AbstractOtelSpringStarterSmokeTest {
2626

2727
@Override
2828
protected void assertAdditionalMetrics() {
29-
if (System.getProperty("org.graalvm.nativeimage.imagecode") != null) {
30-
// GraalVM native image does not support JFR
29+
if (!isFlightRecorderAvailable()) {
3130
return;
3231
}
3332

@@ -50,4 +49,13 @@ protected void assertAdditionalMetrics() {
5049
"io.opentelemetry.runtime-telemetry-java17", metric, AbstractIterableAssert::isNotEmpty);
5150
}
5251
}
52+
53+
private static boolean isFlightRecorderAvailable() {
54+
try {
55+
return (boolean)
56+
Class.forName("jdk.jfr.FlightRecorder").getMethod("isAvailable").invoke(null);
57+
} catch (ReflectiveOperationException exception) {
58+
return false;
59+
}
60+
}
5361
}

0 commit comments

Comments
 (0)