From 2f01d09f8d85c8fd13cad2b1f8830f1e383f54af Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:52:44 -0600 Subject: [PATCH] Recreate graal RetryPolicy issue (#6139) --- .github/workflows/build.yml | 6 +-- ...flect-config.json => resource-config.json} | 0 .../reflect-config.json | 10 ++++ integration-tests/graal/build.gradle.kts | 4 +- .../graal/InitializeSdkTest.java | 53 +++++++++++++++++++ 5 files changed, 69 insertions(+), 4 deletions(-) rename api/all/src/main/resources/META-INF/native-image/io.opentelemetry/opentelemetry-api/{reflect-config.json => resource-config.json} (100%) create mode 100644 exporters/common/src/main/resources/META-INF/native-image/io.opentelemetry.opentelemetry-exporter-common/reflect-config.json create mode 100644 integration-tests/graal/src/test/java/io/opentelemetry/integrationtests/graal/InitializeSdkTest.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8243beff8f7..210f70e2ff7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -136,8 +136,9 @@ jobs: - uses: actions/checkout@v4 - uses: graalvm/setup-graalvm@v1 with: - version: 'latest' - java-version: '17' + # TODO(jack-berg): Which versions do we need to test? Should we use a matrix scheme? + java-version: '21' + distribution: 'graalvm' components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} - name: Running test @@ -145,7 +146,6 @@ jobs: echo "GRAALVM_HOME: $GRAALVM_HOME" echo "JAVA_HOME: $JAVA_HOME" java --version - gu --version native-image --version ./gradlew nativeTest diff --git a/api/all/src/main/resources/META-INF/native-image/io.opentelemetry/opentelemetry-api/reflect-config.json b/api/all/src/main/resources/META-INF/native-image/io.opentelemetry/opentelemetry-api/resource-config.json similarity index 100% rename from api/all/src/main/resources/META-INF/native-image/io.opentelemetry/opentelemetry-api/reflect-config.json rename to api/all/src/main/resources/META-INF/native-image/io.opentelemetry/opentelemetry-api/resource-config.json diff --git a/exporters/common/src/main/resources/META-INF/native-image/io.opentelemetry.opentelemetry-exporter-common/reflect-config.json b/exporters/common/src/main/resources/META-INF/native-image/io.opentelemetry.opentelemetry-exporter-common/reflect-config.json new file mode 100644 index 00000000000..033ccf44f0c --- /dev/null +++ b/exporters/common/src/main/resources/META-INF/native-image/io.opentelemetry.opentelemetry-exporter-common/reflect-config.json @@ -0,0 +1,10 @@ +[ + { + "name":"io.opentelemetry.sdk.common.export.AutoValue_RetryPolicy", + "queryAllDeclaredMethods":true + }, + { + "name":"io.opentelemetry.sdk.common.export.RetryPolicy", + "queryAllDeclaredMethods":true + } +] diff --git a/integration-tests/graal/build.gradle.kts b/integration-tests/graal/build.gradle.kts index cb39297a76a..090be76a2f5 100644 --- a/integration-tests/graal/build.gradle.kts +++ b/integration-tests/graal/build.gradle.kts @@ -16,7 +16,9 @@ sourceSets { } dependencies { - implementation(project(path = ":sdk:trace-shaded-deps")) + implementation(project(":sdk:all")) + implementation(project(":sdk:trace-shaded-deps")) + implementation(project(":exporters:otlp:all")) } // org.graalvm.buildtools.native pluging requires java 11+ as of version 0.9.26 diff --git a/integration-tests/graal/src/test/java/io/opentelemetry/integrationtests/graal/InitializeSdkTest.java b/integration-tests/graal/src/test/java/io/opentelemetry/integrationtests/graal/InitializeSdkTest.java new file mode 100644 index 00000000000..8826db405de --- /dev/null +++ b/integration-tests/graal/src/test/java/io/opentelemetry/integrationtests/graal/InitializeSdkTest.java @@ -0,0 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.integrationtests.graal; + +import static org.assertj.core.api.Assertions.assertThatCode; + +import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter; +import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter; +import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.logs.SdkLoggerProvider; +import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor; +import io.opentelemetry.sdk.metrics.SdkMeterProvider; +import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; +import org.junit.jupiter.api.Test; + +class InitializeSdkTest { + + @Test + void initializeSdk() { + assertThatCode( + () -> { + OpenTelemetrySdk sdk = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .addSpanProcessor( + BatchSpanProcessor.builder(OtlpGrpcSpanExporter.getDefault()) + .build()) + .build()) + .setMeterProvider( + SdkMeterProvider.builder() + .registerMetricReader( + PeriodicMetricReader.create(OtlpGrpcMetricExporter.getDefault())) + .build()) + .setLoggerProvider( + SdkLoggerProvider.builder() + .addLogRecordProcessor( + BatchLogRecordProcessor.builder( + OtlpGrpcLogRecordExporter.getDefault()) + .build()) + .build()) + .build(); + sdk.close(); + }) + .doesNotThrowAnyException(); + } +}