Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java-services] Update java, gradle and OTel agent versions #1183

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/adservice/.java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.0
21.0
7 changes: 3 additions & 4 deletions src/adservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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}
Expand Down
25 changes: 13 additions & 12 deletions src/adservice/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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<Directory> output = layout.buildDirectory.dir("outputLocation")
offlineCompile = output.get().asFile
}

dependencies {
Expand All @@ -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"
}
}

Expand Down
Binary file modified src/adservice/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 4 additions & 3 deletions src/adservice/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
24 changes: 16 additions & 8 deletions src/adservice/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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/.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/adservice/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down
4 changes: 2 additions & 2 deletions src/frauddetectionservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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 ./
Expand Down
18 changes: 9 additions & 9 deletions src/frauddetectionservice/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
}
}
}
}
18 changes: 18 additions & 0 deletions src/frauddetectionservice/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright The OpenTelemetry Authors
SPDX-License-Identifier: Apache-2.0
-->

<Configuration status="WARN">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} - %logger{36} - %msg trace_id=%X{trace_id} span_id=%X{span_id} trace_flags=%X{trace_flags} %n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
2 changes: 1 addition & 1 deletion src/kafka/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading