From d3ded9213a5de50d8aad421b826ed91dcd7a1ea9 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 2 Jun 2025 16:40:25 +0200 Subject: [PATCH 01/21] add test for Mac OS and Windows --- .github/workflows/build.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cebd8993d..893b6cbad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,17 +36,40 @@ jobs: run: ./gradlew build -x test test: - name: test (${{ matrix.test-java-version }}) - runs-on: ubuntu-latest + name: Build + runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: + os: + - macos-latest + - macos-13 + - ubuntu-latest + - windows-latest test-java-version: - 8 - 11 - 17 - 21 - 23 - fail-fast: false + # Collect coverage on latest LTS + include: + - os: ubuntu-latest + test-java-version: 21 + coverage: true + jmh-based-tests: true + # macos-latest drops support for java 8 temurin. Run java 8 on macos-13. Run java 11, 17, 21 on macos-latest. + exclude: + - os: macos-latest + test-java-version: 8 + - os: macos-13 + test-java-version: 11 + - os: macos-13 + test-java-version: 17 + - os: macos-13 + test-java-version: 21 + - os: macos-13 + test-java-version: 23 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 From 4f71158c8586acfbf8d2a10895f915857e2b7640 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 10:00:08 +0200 Subject: [PATCH 02/21] add test for Mac OS and Windows --- .github/workflows/build.yml | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 893b6cbad..f036de8b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,36 +6,17 @@ on: - main - release/* pull_request: - merge_group: workflow_dispatch: -permissions: - contents: read - concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Set up JDK for running Gradle - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 - with: - distribution: temurin - java-version: 17 - - - name: Set up gradle - uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 - with: - cache-read-only: ${{ github.event_name == 'pull_request' }} - - name: Gradle build and test - run: ./gradlew build -x test - - test: name: Build runs-on: ${{ matrix.os }} strategy: @@ -73,15 +54,15 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - id: setup-test-java - name: Set up JDK ${{ matrix.test-java-version }} for running tests + - id: setup-java-test + name: Set up Java ${{ matrix.test-java-version }} for tests uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: - # using zulu because new releases get published quickly - distribution: zulu + distribution: temurin java-version: ${{ matrix.test-java-version }} - - name: Set up JDK for running Gradle + - id: setup-java + name: Set up Java for build uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: distribution: temurin @@ -95,7 +76,7 @@ jobs: run: > ./gradlew test -PtestJavaVersion=${{ matrix.test-java-version }} - -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} + -Porg.gradle.java.installations.paths="${{ steps.setup-test-java.outputs.path }}" -Porg.gradle.java.installations.auto-download=false integration-test: From f8ea293fd482695ef526bbe029acfa7d7ac9769b Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 10:08:48 +0200 Subject: [PATCH 03/21] add test for Mac OS and Windows --- .github/workflows/build.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f036de8b9..188b54fa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,25 @@ permissions: jobs: build: - name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: temurin + java-version: 17 + + - name: Set up gradle + uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 + with: + cache-read-only: ${{ github.event_name == 'pull_request' }} + - name: Gradle build and test + run: ./gradlew build -x test + + test: + name: Test runs-on: ${{ matrix.os }} strategy: fail-fast: false From 7025a82be22b370af370b5f06235d9551b43cff5 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 10:14:46 +0200 Subject: [PATCH 04/21] add test for Mac OS and Windows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 188b54fa0..1b619a1e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,7 +94,7 @@ jobs: run: > ./gradlew test -PtestJavaVersion=${{ matrix.test-java-version }} - -Porg.gradle.java.installations.paths="${{ steps.setup-test-java.outputs.path }}" + "-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}" -Porg.gradle.java.installations.auto-download=false integration-test: From a4463da6e90f839bc30f479710c09c9e0cecfc09 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 11:30:00 +0200 Subject: [PATCH 05/21] add test for Mac OS and Windows --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b619a1e3..874a97ec2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -93,9 +93,9 @@ jobs: - name: Gradle test run: > ./gradlew test - -PtestJavaVersion=${{ matrix.test-java-version }} + "-PtestJavaVersion=${{ matrix.test-java-version }}" "-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}" - -Porg.gradle.java.installations.auto-download=false + "-Porg.gradle.java.installations.auto-download=false" integration-test: runs-on: ubuntu-latest From 6c1af44a7f07687693031cd925090dacb096fe74 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 13:09:58 +0200 Subject: [PATCH 06/21] windows can't clean up the temp dir --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 874a97ec2..32644a08b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,6 +96,7 @@ jobs: "-PtestJavaVersion=${{ matrix.test-java-version }}" "-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}" "-Porg.gradle.java.installations.auto-download=false" + "-Pjunit.jupiter.tempdir.cleanup.mode.default=NEVER" integration-test: runs-on: ubuntu-latest From 433613e4aaca9221836816e44ba274b20d774b97 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 13:40:21 +0200 Subject: [PATCH 07/21] windows can't clean up the temp dir --- .github/workflows/build.yml | 1 - .../buffering/internal/storage/FolderManager.java | 13 ++++++++++++- .../contrib/disk/buffering/IntegrationTest.java | 6 ++++++ .../internal/storage/FolderManagerTest.java | 6 ++++++ .../buffering/internal/storage/StorageTest.java | 6 ++++++ .../internal/storage/files/ReadableFileTest.java | 6 ++++++ .../internal/storage/files/WritableFileTest.java | 6 ++++++ 7 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32644a08b..874a97ec2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,6 @@ jobs: "-PtestJavaVersion=${{ matrix.test-java-version }}" "-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}" "-Porg.gradle.java.installations.auto-download=false" - "-Pjunit.jupiter.tempdir.cleanup.mode.default=NEVER" integration-test: runs-on: ubuntu-latest diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java index 0f3ad7ad7..1f76419ab 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java @@ -11,13 +11,14 @@ import io.opentelemetry.contrib.disk.buffering.internal.storage.files.ReadableFile; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.WritableFile; import io.opentelemetry.sdk.common.Clock; +import java.io.Closeable; import java.io.File; import java.io.IOException; import java.util.Objects; import javax.annotation.Nullable; import org.jetbrains.annotations.NotNull; -public final class FolderManager { +public final class FolderManager implements Closeable { private final File folder; private final Clock clock; private final StorageConfiguration configuration; @@ -30,6 +31,16 @@ public FolderManager(File folder, StorageConfiguration configuration, Clock cloc this.clock = clock; } + @Override + public void close() throws IOException { + if (currentReadableFile != null) { + currentReadableFile.close(); + } + if (currentWritableFile != null) { + currentWritableFile.close(); + } + } + @Nullable public synchronized ReadableFile getReadableFile() throws IOException { currentReadableFile = null; diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java index b2da05c24..b46cba12f 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java @@ -48,6 +48,7 @@ import java.util.function.Function; import java.util.function.Supplier; import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -103,6 +104,11 @@ void setUp() throws IOException { logger = createLoggerProvider(logToDiskExporter).get("LogInstrumentationScope"); } + @AfterEach + void tearDown() throws IOException { + spanStorage.close(); + } + @NotNull private ToDiskExporter buildToDiskExporter( SignalSerializer serializer, Function, CompletableResultCode> exporter) { diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManagerTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManagerTest.java index 0d9e16723..f5b72496a 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManagerTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManagerTest.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -40,6 +41,11 @@ void setUp() { folderManager = new FolderManager(rootDir, TestData.getDefaultConfiguration(rootDir), clock); } + @AfterEach + void tearDown() throws Exception { + folderManager.close(); + } + @Test void createWritableFile_withTimeMillisAsName() throws IOException { when(clock.now()).thenReturn(MILLISECONDS.toNanos(1000L)); diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageTest.java index 9accaefff..7f134afdc 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageTest.java @@ -26,6 +26,7 @@ import java.io.File; import java.io.IOException; import java.util.function.Function; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -47,6 +48,11 @@ void setUp() throws IOException { storage = new Storage(folderManager, true); } + @AfterEach + void tearDown() throws IOException { + storage.close(); + } + @Test void whenReadingAndProcessingSuccessfully_returnSuccess() throws IOException { when(folderManager.getReadableFile()).thenReturn(readableFile); diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFileTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFileTest.java index dd8cb02aa..b54deb7e9 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFileTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFileTest.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -104,6 +105,11 @@ void setUp() throws IOException { source, CREATED_TIME_MILLIS, clock, getConfiguration(temporaryFileProvider, dir)); } + @AfterEach + void tearDown() throws IOException { + readableFile.close(); + } + private static void addFileContents(File source) throws IOException { List items = new ArrayList<>(); items.add(SERIALIZER.serialize(Collections.singleton(FIRST_LOG_RECORD))); diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFileTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFileTest.java index 8ff749c1e..7d3ea3757 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFileTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFileTest.java @@ -22,6 +22,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -47,6 +48,11 @@ void setUp() throws IOException { clock); } + @AfterEach + void tearDown() throws IOException { + writableFile.close(); + } + @Test void hasNotExpired_whenWriteAgeHasNotExpired() { when(clock.now()).thenReturn(MILLISECONDS.toNanos(1500L)); From 79569e61b745f0ed194e89f598bab9073ae62eb4 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 14:22:49 +0200 Subject: [PATCH 08/21] async profiler only works on linux --- .../contrib/inferredspans/InferredSpansAutoConfigTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java index 1b6a7e3e2..8310a4a64 100644 --- a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java +++ b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java @@ -7,6 +7,8 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.condition.OS.LINUX; +import static org.junit.jupiter.api.condition.OS.WINDOWS; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; @@ -31,9 +33,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; +import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.io.TempDir; +@EnabledOnOs(LINUX) public class InferredSpansAutoConfigTest { @BeforeEach @@ -107,7 +110,7 @@ public void checkDisabledbyDefault() { } @DisabledOnOpenJ9 - @DisabledOnOs(OS.WINDOWS) + @DisabledOnOs(WINDOWS) @Test public void checkProfilerWorking() { try (AutoConfigTestProperties props = From 4d5fb9d743e7cc91b3ac3f8a5f4653427aece126 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 14:28:28 +0200 Subject: [PATCH 09/21] avoid rate limiting --- opamp-client/build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index a1f0c698e..206f94d05 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -19,6 +19,8 @@ dependencies { val opampReleaseInfo = tasks.register("opampLastReleaseInfo") { group = "opamp" src("https://api.github.com/repos/open-telemetry/opamp-spec/releases/latest") + header("Authorization", "Bearer ${System.getenv("GITHUB_TOKEN") ?: ""}") + header("X-GitHub-Api-Version", "2022-11-28") dest(project.layout.buildDirectory.file("opamp/release.json")) } From 04ec5aeee2e8a0e8f54a1c437025f385754c7171 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 14:47:46 +0200 Subject: [PATCH 10/21] avoid rate limiting --- .github/workflows/build.yml | 2 ++ opamp-client/build.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 874a97ec2..0f373e454 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,6 +91,8 @@ jobs: with: cache-read-only: ${{ github.event_name == 'pull_request' }} - name: Gradle test + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: > ./gradlew test "-PtestJavaVersion=${{ matrix.test-java-version }}" diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index 206f94d05..08af03149 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { val opampReleaseInfo = tasks.register("opampLastReleaseInfo") { group = "opamp" src("https://api.github.com/repos/open-telemetry/opamp-spec/releases/latest") - header("Authorization", "Bearer ${System.getenv("GITHUB_TOKEN") ?: ""}") + header("Authorization", "Bearer ${System.getenv("GH_TOKEN") ?: ""}") header("X-GitHub-Api-Version", "2022-11-28") dest(project.layout.buildDirectory.file("opamp/release.json")) } From c4b126be51817af8c2a95b6d54ba8ab9343077e7 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 16:25:45 +0200 Subject: [PATCH 11/21] avoid rate limiting --- .github/workflows/build.yml | 3 +++ .github/workflows/codeql.yml | 2 ++ .github/workflows/release.yml | 1 + opamp-client/build.gradle.kts | 9 +++++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f373e454..2669a1257 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,8 @@ jobs: with: cache-read-only: ${{ github.event_name == 'pull_request' }} - name: Gradle build and test + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew build -x test test: @@ -171,6 +173,7 @@ jobs: if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }} run: ./gradlew assemble publishToSonatype env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7906b98c5..2dce10f4b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -49,6 +49,8 @@ jobs: # --no-build-cache is required for codeql to analyze all modules # --no-daemon is required for codeql to observe the compilation # (see https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#specifying-build-commands) + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew assemble --no-build-cache --no-daemon - name: Perform CodeQL analysis diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8fd4f18c0..94df7bfa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -128,6 +128,7 @@ jobs: - name: Build and publish artifacts run: ./gradlew assemble publishToSonatype closeAndReleaseSonatypeStagingRepository env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index 08af03149..dcb40cb2b 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -19,8 +19,13 @@ dependencies { val opampReleaseInfo = tasks.register("opampLastReleaseInfo") { group = "opamp" src("https://api.github.com/repos/open-telemetry/opamp-spec/releases/latest") - header("Authorization", "Bearer ${System.getenv("GH_TOKEN") ?: ""}") - header("X-GitHub-Api-Version", "2022-11-28") + val token = System.getenv("GH_TOKEN") + if (token.isNullOrBlank()) { + logger.warn("No GitHub token found in environment variable GH_TOKEN. Rate limits may apply.") + } else { + header("Authorization", "Bearer $token") + header("X-GitHub-Api-Version", "2022-11-28") + } dest(project.layout.buildDirectory.file("opamp/release.json")) } From 2514e0e0ce214a4a767af21c7d77cf4c381e2165 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 17:15:18 +0200 Subject: [PATCH 12/21] try fix windows --- .../io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java index 2d3178072..36eff9a83 100644 --- a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java +++ b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java @@ -49,7 +49,7 @@ private static void testInvalidArguments(String... args) { void shouldCreateConfig_propertiesLoadedFromFile() throws InvalidArgumentException { // Given String filePath = - ClassLoader.getSystemClassLoader().getResource("validConfig.properties").getPath(); + ClassLoader.getSystemClassLoader().getResource("validConfig.properties").toExternalForm(); List args = Arrays.asList("-config", filePath); // When From ec00af301fe86ab43684a864f7da6f0f4b8ecbd0 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 17:57:37 +0200 Subject: [PATCH 13/21] try fix windows --- .../io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java index 36eff9a83..b51144360 100644 --- a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java +++ b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.java @@ -17,6 +17,8 @@ import java.util.List; import java.util.Properties; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junitpioneer.jupiter.ClearSystemProperty; class JmxScraperTest { @@ -46,10 +48,12 @@ private static void testInvalidArguments(String... args) { } @Test + @DisabledOnOs(OS.WINDOWS) void shouldCreateConfig_propertiesLoadedFromFile() throws InvalidArgumentException { // Given + // Windows returns /C:/path/to/file, which is not a valid path for Path.get() in Java. String filePath = - ClassLoader.getSystemClassLoader().getResource("validConfig.properties").toExternalForm(); + ClassLoader.getSystemClassLoader().getResource("validConfig.properties").getPath(); List args = Arrays.asList("-config", filePath); // When From 12c1df1b30afc65c52d43ece47f366cecb239371 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 4 Jun 2025 18:17:12 +0200 Subject: [PATCH 14/21] comment --- .../contrib/inferredspans/InferredSpansAutoConfigTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java index 8310a4a64..087e8df37 100644 --- a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java +++ b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.io.TempDir; -@EnabledOnOs(LINUX) +@EnabledOnOs(LINUX) // Uses async-profiler, which is only supported on Linux public class InferredSpansAutoConfigTest { @BeforeEach From 6386bd8377553f93aa9ea17af8459967fabd4490 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Thu, 5 Jun 2025 11:08:15 +0200 Subject: [PATCH 15/21] pr feedback --- .github/workflows/build.yml | 7 ++++--- .../contrib/inferredspans/InferredSpansAutoConfigTest.java | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2669a1257..7372e6bd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,15 +6,16 @@ on: - main - release/* pull_request: + merge_group: workflow_dispatch: +permissions: + contents: read + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true -permissions: - contents: read - jobs: build: runs-on: ubuntu-latest diff --git a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java index 087e8df37..76a6333ba 100644 --- a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java +++ b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfigTest.java @@ -7,7 +7,6 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.junit.jupiter.api.condition.OS.LINUX; import static org.junit.jupiter.api.condition.OS.WINDOWS; import io.opentelemetry.api.GlobalOpenTelemetry; @@ -33,10 +32,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.io.TempDir; -@EnabledOnOs(LINUX) // Uses async-profiler, which is only supported on Linux +@DisabledOnOs(WINDOWS) // Uses async-profiler, which is not supported on Windows public class InferredSpansAutoConfigTest { @BeforeEach @@ -110,7 +108,6 @@ public void checkDisabledbyDefault() { } @DisabledOnOpenJ9 - @DisabledOnOs(WINDOWS) @Test public void checkProfilerWorking() { try (AutoConfigTestProperties props = From 80dab064f44ddc657a4b3d4fd7516295ccba33c9 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 18 Jun 2025 10:10:57 -0700 Subject: [PATCH 16/21] testing --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7372e6bd5..02768bc2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,8 +33,6 @@ jobs: with: cache-read-only: ${{ github.event_name == 'pull_request' }} - name: Gradle build and test - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew build -x test test: @@ -174,7 +172,6 @@ jobs: if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }} run: ./gradlew assemble publishToSonatype env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} From ce6b0e759473f155b2da1cd4708ff4ed5789225a Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Tue, 24 Jun 2025 10:49:20 +0200 Subject: [PATCH 17/21] pr feedback --- .github/workflows/build.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02768bc2f..795110c59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,12 +52,6 @@ jobs: - 17 - 21 - 23 - # Collect coverage on latest LTS - include: - - os: ubuntu-latest - test-java-version: 21 - coverage: true - jmh-based-tests: true # macos-latest drops support for java 8 temurin. Run java 8 on macos-13. Run java 11, 17, 21 on macos-latest. exclude: - os: macos-latest @@ -97,7 +91,7 @@ jobs: run: > ./gradlew test "-PtestJavaVersion=${{ matrix.test-java-version }}" - "-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}" + "-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }}" "-Porg.gradle.java.installations.auto-download=false" integration-test: From 26f5ca17bd4db8d36ce049004bc6a7f0a54943fa Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 28 Jun 2025 16:22:10 -0700 Subject: [PATCH 18/21] Avoid GitHub Rest API which is heavily throttled --- opamp-client/build.gradle.kts | 44 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index dcb40cb2b..f0a577cf7 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -1,6 +1,7 @@ import de.undercouch.gradle.tasks.download.Download import de.undercouch.gradle.tasks.download.DownloadExtension -import groovy.json.JsonSlurper +import java.net.HttpURLConnection +import java.net.URL plugins { id("otel.java-conventions") @@ -16,26 +17,9 @@ dependencies { compileOnly("com.google.auto.value:auto-value-annotations") } -val opampReleaseInfo = tasks.register("opampLastReleaseInfo") { - group = "opamp" - src("https://api.github.com/repos/open-telemetry/opamp-spec/releases/latest") - val token = System.getenv("GH_TOKEN") - if (token.isNullOrBlank()) { - logger.warn("No GitHub token found in environment variable GH_TOKEN. Rate limits may apply.") - } else { - header("Authorization", "Bearer $token") - header("X-GitHub-Api-Version", "2022-11-28") - } - dest(project.layout.buildDirectory.file("opamp/release.json")) -} - val opampProtos = tasks.register("opampProtoDownload", download) opampProtos.configure { group = "opamp" - dependsOn(opampReleaseInfo) - lastReleaseInfoJson.set { - opampReleaseInfo.get().dest - } outputProtosDir.set(project.layout.buildDirectory.dir("opamp/protos")) downloadedZipFile.set(project.layout.buildDirectory.file("intermediate/$name/release.zip")) } @@ -53,20 +37,32 @@ abstract class DownloadOpampProtos @Inject constructor( private val fileOps: FileSystemOperations, ) : DefaultTask() { - @get:InputFile - abstract val lastReleaseInfoJson: RegularFileProperty - @get:OutputDirectory abstract val outputProtosDir: DirectoryProperty @get:Internal abstract val downloadedZipFile: RegularFileProperty - @Suppress("UNCHECKED_CAST") @TaskAction fun execute() { - val releaseInfo = JsonSlurper().parse(lastReleaseInfoJson.get().asFile) as Map - val zipUrl = releaseInfo["zipball_url"] + // Get the latest release tag by following the redirect from GitHub's latest release URL + val latestReleaseUrl = "https://github.com/open-telemetry/opamp-spec/releases/latest" + val connection = URL(latestReleaseUrl).openConnection() as HttpURLConnection + connection.instanceFollowRedirects = false + connection.requestMethod = "HEAD" + + val redirectLocation = connection.getHeaderField("Location") + connection.disconnect() + + val latestTag = if (redirectLocation != null && redirectLocation.contains("/releases/tag/")) { + // Extract tag from URL like: https://github.com/open-telemetry/opamp-spec/releases/tag/v0.12.0 + redirectLocation.substringAfterLast("/") + } else { + throw RuntimeException("Could not determine latest release tag from redirect. Redirect location: $redirectLocation") + } + // Download the source code for the latest release + val zipUrl = "https://github.com/open-telemetry/opamp-spec/zipball/$latestTag" + download.run { src(zipUrl) dest(downloadedZipFile) From cea75413958a303e644409774a9cb161fa71d5bb Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 28 Jun 2025 16:24:09 -0700 Subject: [PATCH 19/21] token no longer needed --- .github/workflows/build.yml | 2 -- .github/workflows/codeql.yml | 2 -- .github/workflows/release.yml | 1 - 3 files changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 795110c59..7efc2bc52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,8 +86,6 @@ jobs: with: cache-read-only: ${{ github.event_name == 'pull_request' }} - name: Gradle test - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: > ./gradlew test "-PtestJavaVersion=${{ matrix.test-java-version }}" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2dce10f4b..7906b98c5 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -49,8 +49,6 @@ jobs: # --no-build-cache is required for codeql to analyze all modules # --no-daemon is required for codeql to observe the compilation # (see https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#specifying-build-commands) - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew assemble --no-build-cache --no-daemon - name: Perform CodeQL analysis diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94df7bfa9..8fd4f18c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -128,7 +128,6 @@ jobs: - name: Build and publish artifacts run: ./gradlew assemble publishToSonatype closeAndReleaseSonatypeStagingRepository env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} From 0333f61ec68247c0c6418f67b49615235afa5b6a Mon Sep 17 00:00:00 2001 From: otelbot <197425009+otelbot@users.noreply.github.com> Date: Sat, 28 Jun 2025 23:26:55 +0000 Subject: [PATCH 20/21] ./gradlew spotlessApply --- opamp-client/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index f0a577cf7..08126373f 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -1,4 +1,3 @@ -import de.undercouch.gradle.tasks.download.Download import de.undercouch.gradle.tasks.download.DownloadExtension import java.net.HttpURLConnection import java.net.URL From 11795cd57f7fd4f692e58092f880922491edd661 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 28 Jun 2025 16:45:49 -0700 Subject: [PATCH 21/21] optimistic --- opamp-client/build.gradle.kts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index 08126373f..5b4b5bf7e 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -53,12 +53,8 @@ abstract class DownloadOpampProtos @Inject constructor( val redirectLocation = connection.getHeaderField("Location") connection.disconnect() - val latestTag = if (redirectLocation != null && redirectLocation.contains("/releases/tag/")) { - // Extract tag from URL like: https://github.com/open-telemetry/opamp-spec/releases/tag/v0.12.0 - redirectLocation.substringAfterLast("/") - } else { - throw RuntimeException("Could not determine latest release tag from redirect. Redirect location: $redirectLocation") - } + // Extract tag from URL like: https://github.com/open-telemetry/opamp-spec/releases/tag/v0.12.0 + val latestTag = redirectLocation.substringAfterLast("/") // Download the source code for the latest release val zipUrl = "https://github.com/open-telemetry/opamp-spec/zipball/$latestTag"