diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b1568924d..b7f5b72afd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ release. ([#1162](https://github.com/open-telemetry/opentelemetry-demo/pull/1162)) * [otelcol] merge configuration files for base and observability configs ([#1173](https://github.com/open-telemetry/opentelemetry-demo/pull/1173)) +* [java-services] Update java, gradle and OTel agent versions + ([#1183](https://github.com/open-telemetry/opentelemetry-demo/pull/1183)) ## 1.5.0 diff --git a/src/adservice/.java-version b/src/adservice/.java-version index 03b6389f32..5f39e91446 100644 --- a/src/adservice/.java-version +++ b/src/adservice/.java-version @@ -1 +1 @@ -17.0 +21.0 diff --git a/src/adservice/Dockerfile b/src/adservice/Dockerfile index 442b69120d..425960e9c0 100644 --- a/src/adservice/Dockerfile +++ b/src/adservice/Dockerfile @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 -FROM eclipse-temurin:17-jdk AS builder +FROM eclipse-temurin:21-jdk as builder WORKDIR /usr/src/app/ @@ -18,14 +18,13 @@ RUN ./gradlew installDist -PprotoSourceDir=./proto # ----------------------------------------------------------------------------- -FROM eclipse-temurin:17-jre +FROM eclipse-temurin:21-jre -ARG version=1.30.0 +ARG version=1.31.0 WORKDIR /usr/src/app/ COPY --from=builder /usr/src/app/ ./ ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /usr/src/app/opentelemetry-javaagent.jar -RUN chmod 644 /usr/src/app/opentelemetry-javaagent.jar ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar EXPOSE ${AD_SERVICE_PORT} diff --git a/src/adservice/build.gradle b/src/adservice/build.gradle index dfc4058911..918fda0abd 100644 --- a/src/adservice/build.gradle +++ b/src/adservice/build.gradle @@ -16,20 +16,21 @@ description = 'Ad Service' group = "adservice" version = "0.1.0-SNAPSHOT" -def opentelemetryVersion = "1.28.0" -def opentelemetryInstrumentationAlphaVersion = "1.28.0-alpha" -def grpcVersion = "1.56.1" -def jacksonVersion = "2.15.2" -def protocVersion = "3.20.0" - -tasks.withType(JavaCompile) { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 +def opentelemetryVersion = "1.31.0" +def opentelemetryInstrumentationAlphaVersion = "1.31.0-alpha" +def grpcVersion = "1.58.0" +def jacksonVersion = "2.15.3" +def protocVersion = "3.24.4" + +tasks.withType(JavaCompile).configureEach { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } ext { speed = project.hasProperty('speed') ? project.getProperty('speed') : false - offlineCompile = new File("$buildDir/output/lib") + Provider output = layout.buildDirectory.dir("outputLocation") + offlineCompile = output.get().asFile } dependencies { @@ -48,11 +49,11 @@ dependencies { "io.opentelemetry:opentelemetry-api", "io.opentelemetry:opentelemetry-sdk", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations", - "org.apache.logging.log4j:log4j-core:2.20.0" + "org.apache.logging.log4j:log4j-core:2.21.0" runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}", "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}", - "io.netty:netty-tcnative-boringssl-static:2.0.61.Final" + "io.netty:netty-tcnative-boringssl-static:2.0.62.Final" } } diff --git a/src/adservice/gradle/wrapper/gradle-wrapper.jar b/src/adservice/gradle/wrapper/gradle-wrapper.jar index 249e5832f0..033e24c4cd 100644 Binary files a/src/adservice/gradle/wrapper/gradle-wrapper.jar and b/src/adservice/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/adservice/gradle/wrapper/gradle-wrapper.properties b/src/adservice/gradle/wrapper/gradle-wrapper.properties index 165b5020b0..3fa8f862f7 100644 --- a/src/adservice/gradle/wrapper/gradle-wrapper.properties +++ b/src/adservice/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Wed Jul 19 11:27:42 EDT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/adservice/gradlew b/src/adservice/gradlew index a69d9cb6c2..fcb6fca147 100755 --- a/src/adservice/gradlew +++ b/src/adservice/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/src/adservice/gradlew.bat b/src/adservice/gradlew.bat index 53a6b238d4..6689b85bee 100644 --- a/src/adservice/gradlew.bat +++ b/src/adservice/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/src/frauddetectionservice/Dockerfile b/src/frauddetectionservice/Dockerfile index 41116a73bf..925728a30c 100644 --- a/src/frauddetectionservice/Dockerfile +++ b/src/frauddetectionservice/Dockerfile @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 -FROM gradle:7-jdk17 AS builder +FROM gradle:8-jdk17 AS builder WORKDIR /usr/src/app/ @@ -14,7 +14,7 @@ RUN gradle shadowJar FROM gcr.io/distroless/java17-debian11 -ARG version=1.30.0 +ARG version=1.31.0 WORKDIR /usr/src/app/ COPY --from=builder /usr/src/app/build/libs/frauddetectionservice-1.0-all.jar ./ diff --git a/src/frauddetectionservice/build.gradle.kts b/src/frauddetectionservice/build.gradle.kts index 86c569e7f0..64857abc34 100644 --- a/src/frauddetectionservice/build.gradle.kts +++ b/src/frauddetectionservice/build.gradle.kts @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import com.google.protobuf.gradle.* plugins { - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "1.9.10" application id("java") id("idea") @@ -15,8 +15,8 @@ group = "io.opentelemetry" version = "1.0" -val grpcVersion = "1.56.1" -val protobufVersion = "3.23.4" +val grpcVersion = "1.58.0" +val protobufVersion = "3.24.4" repositories { @@ -30,17 +30,17 @@ dependencies { implementation("com.google.protobuf:protobuf-java:${protobufVersion}") testImplementation(kotlin("test")) implementation(kotlin("script-runtime")) - implementation("org.apache.kafka:kafka-clients:3.5.1") - implementation("com.google.api.grpc:proto-google-common-protos:2.22.1") + implementation("org.apache.kafka:kafka-clients:3.6.0") + implementation("com.google.api.grpc:proto-google-common-protos:2.26.0") implementation("io.grpc:grpc-protobuf:${grpcVersion}") implementation("io.grpc:grpc-stub:${grpcVersion}") implementation("io.grpc:grpc-netty:${grpcVersion}") implementation("io.grpc:grpc-services:${grpcVersion}") - implementation("io.opentelemetry:opentelemetry-api:1.28.0") - implementation("io.opentelemetry:opentelemetry-sdk:1.28.0") + implementation("io.opentelemetry:opentelemetry-api:1.31.0") + implementation("io.opentelemetry:opentelemetry-sdk:1.31.0") implementation("io.opentelemetry:opentelemetry-extension-annotations:1.18.0") - implementation("org.apache.logging.log4j:log4j-core:2.20.0") - implementation("org.slf4j:slf4j-api:2.0.7") + implementation("org.apache.logging.log4j:log4j-core:2.21.0") + implementation("org.slf4j:slf4j-api:2.0.9") implementation("com.google.protobuf:protobuf-kotlin:${protobufVersion}") if (JavaVersion.current().isJava9Compatible) { diff --git a/src/frauddetectionservice/gradle/wrapper/gradle-wrapper.properties b/src/frauddetectionservice/gradle/wrapper/gradle-wrapper.properties index 9f4197d5f4..3fa8f862f7 100644 --- a/src/frauddetectionservice/gradle/wrapper/gradle-wrapper.properties +++ b/src/frauddetectionservice/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/frauddetectionservice/src/main/kotlin/frauddetectionservice/main.kt b/src/frauddetectionservice/src/main/kotlin/frauddetectionservice/main.kt index 581134ad42..009a849764 100644 --- a/src/frauddetectionservice/src/main/kotlin/frauddetectionservice/main.kt +++ b/src/frauddetectionservice/src/main/kotlin/frauddetectionservice/main.kt @@ -1,18 +1,26 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ package frauddetectionservice import org.apache.kafka.clients.consumer.ConsumerConfig.* import org.apache.kafka.clients.consumer.KafkaConsumer -import org.apache.kafka.common.serialization.StringDeserializer import org.apache.kafka.common.serialization.ByteArrayDeserializer +import org.apache.kafka.common.serialization.StringDeserializer +import org.apache.logging.log4j.LogManager +import org.apache.logging.log4j.Logger import oteldemo.Demo.* import java.time.Duration.ofMillis -import java.util.Properties +import java.util.* import kotlin.system.exitProcess const val topic = "orders" const val groupID = "frauddetectionservice" +private val logger: Logger = LogManager.getLogger(groupID) + fun main() { val props = Properties() props[KEY_DESERIALIZER_CLASS_CONFIG] = StringDeserializer::class.java.name @@ -37,9 +45,9 @@ fun main() { .fold(totalCount) { accumulator, record -> val newCount = accumulator + 1 val orders = OrderResult.parseFrom(record.value()) - println("Consumed record with orderId: ${orders.orderId}, and updated total count to: $newCount") + logger.info("Consumed record with orderId: ${orders.orderId}, and updated total count to: $newCount") newCount } } } -} \ No newline at end of file +} diff --git a/src/frauddetectionservice/src/main/resources/log4j2.xml b/src/frauddetectionservice/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..db5cb39e96 --- /dev/null +++ b/src/frauddetectionservice/src/main/resources/log4j2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/src/kafka/Dockerfile b/src/kafka/Dockerfile index 91758ddcee..37468658ea 100644 --- a/src/kafka/Dockerfile +++ b/src/kafka/Dockerfile @@ -5,7 +5,7 @@ FROM confluentinc/cp-kafka:7.5.0 USER root -ARG version=1.30.0 +ARG version=1.31.0 ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /tmp/opentelemetry-javaagent.jar RUN chmod go+r /tmp/opentelemetry-javaagent.jar