Fix OpenJ9 test failure (#13311)

This commit is contained in:
Trask Stalnaker 2025-02-15 14:53:49 -08:00 committed by GitHub
parent cb16d45973
commit 9e7edab6e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -26,8 +26,7 @@ class OtelSpringStarterSmokeTest extends AbstractOtelSpringStarterSmokeTest {
@Override
protected void assertAdditionalMetrics() {
if (System.getProperty("org.graalvm.nativeimage.imagecode") != null) {
// GraalVM native image does not support JFR
if (!isFlightRecorderAvailable()) {
return;
}
@ -50,4 +49,13 @@ class OtelSpringStarterSmokeTest extends AbstractOtelSpringStarterSmokeTest {
"io.opentelemetry.runtime-telemetry-java17", metric, AbstractIterableAssert::isNotEmpty);
}
}
private static boolean isFlightRecorderAvailable() {
try {
return (boolean)
Class.forName("jdk.jfr.FlightRecorder").getMethod("isAvailable").invoke(null);
} catch (ReflectiveOperationException exception) {
return false;
}
}
}