diff --git a/.env.arm64 b/.env.arm64 new file mode 100644 index 0000000000..92b04b3a5f --- /dev/null +++ b/.env.arm64 @@ -0,0 +1 @@ +_JAVA_OPTIONS=-XX:UseSVE=0 diff --git a/Makefile b/Makefile index 7bb2f27153..b0dcc011b7 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,15 @@ MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY) DOCKER_COMPOSE_CMD ?= docker compose DOCKER_COMPOSE_ENV=--env-file .env --env-file .env.override +DOCKER_COMPOSE_BUILD_ARGS= + +# Java Workaround for macOS 15.2+ and M4 chips (see https://bugs.openjdk.org/browse/JDK-8345296) +ifeq ($(shell uname -m),arm64) + ifeq ($(shell uname -s),Darwin) + DOCKER_COMPOSE_ENV+= --env-file .env.arm64 + DOCKER_COMPOSE_BUILD_ARGS+= --build-arg=_JAVA_OPTIONS=-XX:UseSVE=0 + endif +endif # see https://github.com/open-telemetry/build-tools/releases for semconvgen updates # Keep links in semantic_conventions/README.md and .vscode/settings.json in sync! @@ -77,11 +86,11 @@ install-tools: $(MISSPELL) .PHONY: build build: - $(DOCKER_COMPOSE_CMD) build + $(DOCKER_COMPOSE_CMD) build $(DOCKER_COMPOSE_BUILD_ARGS) .PHONY: build-and-push build-and-push: - $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build --push + $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) --push # Create multiplatform builder for buildx .PHONY: create-multiplatform-builder @@ -209,7 +218,7 @@ ifdef SERVICE endif ifdef service - $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(service) + $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) $(service) $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) stop $(service) $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) rm --force $(service) $(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) create $(service) diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 9d2da324fb..9a8d67b5ba 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -45,7 +45,7 @@ services: - OTEL_LOGS_EXPORTER=otlp - OTEL_SERVICE_NAME=ad # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 + - _JAVA_OPTIONS depends_on: otel-collector: condition: service_started @@ -657,7 +657,7 @@ services: - DISABLE_INSTALL_DEMO_CONFIG=true - DISABLE_SECURITY_PLUGIN=true # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 + - _JAVA_OPTIONS ulimits: memlock: soft: -1 diff --git a/docker-compose.yml b/docker-compose.yml index b4f0d0a304..aa3911d169 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,7 +72,7 @@ services: - OTEL_LOGS_EXPORTER=otlp - OTEL_SERVICE_NAME=ad # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 + - _JAVA_OPTIONS depends_on: otel-collector: condition: service_started @@ -247,8 +247,6 @@ services: - OTEL_INSTRUMENTATION_MESSAGING_EXPERIMENTAL_RECEIVE_TELEMETRY_ENABLED=true - OTEL_RESOURCE_ATTRIBUTES - OTEL_SERVICE_NAME=fraud-detection - # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 depends_on: otel-collector: condition: service_started @@ -663,7 +661,7 @@ services: - OTEL_SERVICE_NAME=kafka - KAFKA_HEAP_OPTS=-Xmx400m -Xms400m # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 + - _JAVA_OPTIONS healthcheck: test: nc -z kafka 9092 start_period: 10s @@ -805,7 +803,7 @@ services: - DISABLE_INSTALL_DEMO_CONFIG=true - DISABLE_SECURITY_PLUGIN=true # Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296 - - _JAVA_OPTIONS=-XX:UseSVE=0 + - _JAVA_OPTIONS ulimits: memlock: soft: -1 diff --git a/src/ad/Dockerfile b/src/ad/Dockerfile index 66733bfe50..1b59165945 100644 --- a/src/ad/Dockerfile +++ b/src/ad/Dockerfile @@ -3,7 +3,7 @@ FROM --platform=${BUILDPLATFORM} eclipse-temurin:21-jdk AS builder -ENV _JAVA_OPTIONS=-XX:UseSVE=0 +ARG _JAVA_OPTIONS WORKDIR /usr/src/app/ COPY ./src/ad/gradlew* ./src/ad/settings.gradle* ./src/ad/build.gradle ./ @@ -23,11 +23,12 @@ RUN ./gradlew installDist -PprotoSourceDir=./proto FROM eclipse-temurin:21-jre ARG OTEL_JAVA_AGENT_VERSION +ARG _JAVA_OPTIONS + WORKDIR /usr/src/app/ COPY --from=builder /usr/src/app/ ./ ADD --chmod=644 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$OTEL_JAVA_AGENT_VERSION/opentelemetry-javaagent.jar /usr/src/app/opentelemetry-javaagent.jar -ENV _JAVA_OPTIONS="-XX:UseSVE=0" ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar EXPOSE ${AD_PORT}