Skip to content

Commit

Permalink
Update dependencies in OpenTelemetry Java sample
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Vitale <[email protected]>
  • Loading branch information
ThomasVitale authored and anthonydahanne committed Jun 13, 2024
1 parent be8dfe1 commit 3813cb5
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/java-opentelemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [11]
java: [17]

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/.bin
.idea/
.idea/

### macOS ###
.DS_Store
*.DS_Store
**/.DS_Store
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ A collection of sample applications that can be built using Paketo Buildpacks.
* [Leiningen (Clojure)](/java/leiningen)
* [Maven](/java/maven)
* [Native Image](/java/native-image)
* [OpenTelemetry](/java/opentelemetry)
* [Pre-compiled JAR](/java/jar)
* [Scala Akka](/java/akka)
* [WAR](/java/war)
Expand Down
1 change: 1 addition & 0 deletions java/opentelemetry/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
HELP.md
.gradle
build/
bin/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**
!**/src/test/**
Expand Down
10 changes: 7 additions & 3 deletions java/opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pack build applications/opentelemetry \
--buildpack paketo-buildpacks/java \
--buildpack gcr.io/paketo-buildpacks/opentelemetry \
--env BP_OPENTELEMETRY_ENABLED=true \
--env BP_JVM_VERSION=11
--env BP_JVM_VERSION=17
```

## Running
Expand Down Expand Up @@ -48,7 +48,9 @@ The result will be:
```bash
[
"OTEL_JAVAAGENT_ENABLED=true",
"OTEL_SERVICE_NAME=null"
"OTEL_SERVICE_NAME=null",
"OTEL_LOGS_EXPORTER=none",
"OTEL_METRICS_EXPORTER=none"
]
```

Expand All @@ -57,6 +59,8 @@ If you configured the `OTEL_SERVICE_NAME` property (either via environment varia
```bash
[
"OTEL_JAVAAGENT_ENABLED=true",
"OTEL_SERVICE_NAME=myapp"
"OTEL_SERVICE_NAME=myapp",
"OTEL_LOGS_EXPORTER=none",
"OTEL_METRICS_EXPORTER=none"
]
```
1 change: 1 addition & 0 deletions java/opentelemetry/bin/main/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

25 changes: 15 additions & 10 deletions java/opentelemetry/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
plugins {
id 'org.springframework.boot' version '2.7.15'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
id 'java'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
}

group = 'io.paketo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

jar {
enabled = false
enabled = false
}

repositories {
Expand All @@ -18,11 +23,11 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
testImplementation'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
useJUnitPlatform()
tasks.named('test') {
useJUnitPlatform()
}
Binary file modified java/opentelemetry/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion java/opentelemetry/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 18 additions & 13 deletions java/opentelemetry/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/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/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 Down Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,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
# shellcheck disable=SC2039,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
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions java/opentelemetry/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.RouterFunctions;
import org.springframework.web.servlet.function.ServerResponse;

@SpringBootApplication
public class DemoApplication {
Expand All @@ -19,10 +19,12 @@ public static void main(String[] args) {
@Bean
RouterFunction<ServerResponse> routerFunction() {
return RouterFunctions.route()
.GET("/", request -> ServerResponse.ok().bodyValue("Hello, OpenTelemetry!"))
.GET("/config", request -> ServerResponse.ok().bodyValue(List.of(
.GET("/", request -> ServerResponse.ok().body("Hello, OpenTelemetry!"))
.GET("/config", request -> ServerResponse.ok().body(List.of(
"OTEL_JAVAAGENT_ENABLED=" + System.getenv("OTEL_JAVAAGENT_ENABLED"),
"OTEL_SERVICE_NAME=" + System.getenv("OTEL_SERVICE_NAME")
"OTEL_SERVICE_NAME=" + System.getenv("OTEL_SERVICE_NAME"),
"OTEL_LOGS_EXPORTER=" + System.getenv("OTEL_LOGS_EXPORTER"),
"OTEL_METRICS_EXPORTER=" + System.getenv("OTEL_METRICS_EXPORTER")
)))
.build();
}
Expand Down

0 comments on commit 3813cb5

Please sign in to comment.