diff --git a/benchmark-overhead-jmh/build.gradle.kts b/benchmark-overhead-jmh/build.gradle.kts index 2d6498889d45..0066d74ae776 100644 --- a/benchmark-overhead-jmh/build.gradle.kts +++ b/benchmark-overhead-jmh/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } dependencies { - jmhImplementation("org.springframework.boot:spring-boot-starter-web:3.1.3") + jmhImplementation("org.springframework.boot:spring-boot-starter-web:3.1.4") } tasks { diff --git a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts index 7060dc42bc5c..a40e8c183db0 100644 --- a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts @@ -122,7 +122,7 @@ abstract class NettyAlignmentRule : ComponentMetadataRule { with(ctx.details) { if (id.group == "io.netty" && id.name != "netty") { if (id.version.startsWith("4.1.")) { - belongsTo("io.netty:netty-bom:4.1.97.Final", false) + belongsTo("io.netty:netty-bom:4.1.98.Final", false) } else if (id.version.startsWith("4.0.")) { belongsTo("io.netty:netty-bom:4.0.56.Final", false) } diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index e32fd54e60f1..8a0a7d638730 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -108,7 +108,7 @@ val DEPENDENCIES = listOf( "org.junit-pioneer:junit-pioneer:1.9.1", "org.objenesis:objenesis:3.3", // Note that this is only referenced as "org.springframework.boot" in build files, not the artifact name. - "org.springframework.boot:spring-boot-dependencies:2.7.15", + "org.springframework.boot:spring-boot-dependencies:2.7.16", "javax.validation:validation-api:2.0.1.Final", "org.snakeyaml:snakeyaml-engine:2.7" ) diff --git a/instrumentation/spring/spring-boot-resources/library/src/main/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetector.java b/instrumentation/spring/spring-boot-resources/library/src/main/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetector.java index e6a0549d3621..83e2daf73780 100644 --- a/instrumentation/spring/spring-boot-resources/library/src/main/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetector.java +++ b/instrumentation/spring/spring-boot-resources/library/src/main/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetector.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.spring.resources; import static java.util.logging.Level.FINE; +import static java.util.logging.Level.FINER; import com.google.auto.service.AutoService; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; @@ -20,7 +21,6 @@ import java.util.Properties; import java.util.function.Function; import java.util.function.Supplier; -import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -69,7 +69,7 @@ public SpringBootServiceNameDetector() { @Override public Resource createResource(ConfigProperties config) { - logger.log(Level.FINER, "Performing Spring Boot service name auto-detection..."); + logger.log(FINER, "Performing Spring Boot service name auto-detection..."); // Note: The order should be consistent with the order of Spring matching, but noting // that we have "first one wins" while Spring has "last one wins". // The docs for Spring are here: @@ -80,8 +80,10 @@ public Resource createResource(ConfigProperties config) { this::findBySystemProperties, this::findByEnvironmentVariable, this::findByCurrentDirectoryApplicationProperties, + this::findByCurrentDirectoryApplicationYml, this::findByCurrentDirectoryApplicationYaml, this::findByClasspathApplicationProperties, + this::findByClasspathApplicationYml, this::findByClasspathApplicationYaml); return finders .map(Supplier::get) @@ -115,14 +117,14 @@ public int order() { @Nullable private String findByEnvironmentVariable() { String result = system.getenv("SPRING_APPLICATION_NAME"); - logger.log(Level.FINER, "Checking for SPRING_APPLICATION_NAME in env: {0}", result); + logger.log(FINER, "Checking for SPRING_APPLICATION_NAME in env: {0}", result); return result; } @Nullable private String findBySystemProperties() { String result = system.getProperty("spring.application.name"); - logger.log(Level.FINER, "Checking for spring.application.name system property: {0}", result); + logger.log(FINER, "Checking for spring.application.name system property: {0}", result); return result; } @@ -130,9 +132,7 @@ private String findBySystemProperties() { private String findByClasspathApplicationProperties() { String result = readNameFromAppProperties(); logger.log( - Level.FINER, - "Checking for spring.application.name in application.properties file: {0}", - result); + FINER, "Checking for spring.application.name in application.properties file: {0}", result); return result; } @@ -144,27 +144,49 @@ private String findByCurrentDirectoryApplicationProperties() { } catch (Exception e) { // expected to fail sometimes } - logger.log(Level.FINER, "Checking application.properties in current dir: {0}", result); + logger.log(FINER, "Checking application.properties in current dir: {0}", result); return result; } + @Nullable + private String findByClasspathApplicationYml() { + return findByClasspathYamlFile("application.yml"); + } + @Nullable private String findByClasspathApplicationYaml() { - String result = - loadFromClasspath("application.yml", SpringBootServiceNameDetector::parseNameFromYaml); - logger.log(Level.FINER, "Checking application.yml in classpath: {0}", result); + return findByClasspathYamlFile("application.yaml"); + } + + private String findByClasspathYamlFile(String fileName) { + String result = loadFromClasspath(fileName, SpringBootServiceNameDetector::parseNameFromYaml); + if (logger.isLoggable(FINER)) { + logger.log(FINER, "Checking {0} in classpath: {1}", new Object[] {fileName, result}); + } return result; } + @Nullable + private String findByCurrentDirectoryApplicationYml() { + return findByCurrentDirectoryYamlFile("application.yml"); + } + @Nullable private String findByCurrentDirectoryApplicationYaml() { + return findByCurrentDirectoryYamlFile("application.yaml"); + } + + @Nullable + private String findByCurrentDirectoryYamlFile(String fileName) { String result = null; - try (InputStream in = system.openFile("application.yml")) { + try (InputStream in = system.openFile(fileName)) { result = parseNameFromYaml(in); } catch (Exception e) { // expected to fail sometimes } - logger.log(Level.FINER, "Checking application.yml in current dir: {0}", result); + if (logger.isLoggable(FINER)) { + logger.log(FINER, "Checking {0} in current dir: {1}", new Object[] {fileName, result}); + } return result; } @@ -199,7 +221,7 @@ private String findByCommandlineArgument() { String javaCommand = system.getProperty("sun.java.command"); result = parseNameFromCommandLine(javaCommand); } - logger.log(Level.FINER, "Checking application commandline args: {0}", result); + logger.log(FINER, "Checking application commandline args: {0}", result); return result; } diff --git a/instrumentation/spring/spring-boot-resources/library/src/test/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetectorTest.java b/instrumentation/spring/spring-boot-resources/library/src/test/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetectorTest.java index 0d10364649d6..bd0c5bd6c953 100644 --- a/instrumentation/spring/spring-boot-resources/library/src/test/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetectorTest.java +++ b/instrumentation/spring/spring-boot-resources/library/src/test/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceNameDetectorTest.java @@ -22,6 +22,8 @@ import java.nio.file.Paths; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -66,18 +68,19 @@ void propertiesFileInCurrentDir() throws Exception { } } - @Test - void classpathApplicationYaml() { - when(system.openClasspathResource(APPLICATION_YML)) - .thenReturn(openClasspathResource(APPLICATION_YML)); + @ParameterizedTest + @ValueSource(strings = {"application.yaml", APPLICATION_YML}) + void classpathApplicationYaml(String fileName) { + when(system.openClasspathResource(fileName)).thenReturn(openClasspathResource(APPLICATION_YML)); SpringBootServiceNameDetector guesser = new SpringBootServiceNameDetector(system); Resource result = guesser.createResource(config); expectServiceName(result, "cat-store"); } - @Test - void classpathApplicationYamlContainingMultipleYamlDefinitions() { - when(system.openClasspathResource(APPLICATION_YML)) + @ParameterizedTest + @ValueSource(strings = {"application.yaml", APPLICATION_YML}) + void classpathApplicationYamlContainingMultipleYamlDefinitions(String fileName) { + when(system.openClasspathResource(fileName)) .thenReturn( ClassLoader.getSystemClassLoader().getResourceAsStream("application-multi.yml")); SpringBootServiceNameDetector guesser = new SpringBootServiceNameDetector(system); @@ -85,14 +88,15 @@ void classpathApplicationYamlContainingMultipleYamlDefinitions() { expectServiceName(result, "cat-store"); } - @Test - void yamlFileInCurrentDir() throws Exception { - Path yamlPath = Paths.get(APPLICATION_YML); + @ParameterizedTest + @ValueSource(strings = {"application.yaml", APPLICATION_YML}) + void yamlFileInCurrentDir(String fileName) throws Exception { + Path yamlPath = Paths.get(fileName); try { URL url = getClass().getClassLoader().getResource(APPLICATION_YML); String content = readString(Paths.get(url.toURI())); writeString(yamlPath, content); - when(system.openFile(APPLICATION_YML)).thenCallRealMethod(); + when(system.openFile(fileName)).thenCallRealMethod(); SpringBootServiceNameDetector guesser = new SpringBootServiceNameDetector(system); Resource result = guesser.createResource(config); expectServiceName(result, "cat-store"); @@ -117,7 +121,7 @@ void getFromCommandlineArgsWithProcessHandle() throws Exception { } @Test - void getFromCommandlineArgsWithSystemProperty() throws Exception { + void getFromCommandlineArgsWithSystemProperty() { when(system.getProperty("sun.java.command")) .thenReturn("/bin/java sweet-spring.jar --spring.application.name=bullpen --quiet=never"); SpringBootServiceNameDetector guesser = new SpringBootServiceNameDetector(system); diff --git a/smoke-tests-otel-starter/build.gradle.kts b/smoke-tests-otel-starter/build.gradle.kts index 4363a7326662..f9472c4cf4cd 100644 --- a/smoke-tests-otel-starter/build.gradle.kts +++ b/smoke-tests-otel-starter/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("otel.java-conventions") - id("org.springframework.boot") version "3.1.3" + id("org.springframework.boot") version "3.1.4" id("org.graalvm.buildtools.native") } diff --git a/smoke-tests/images/spring-boot/build.gradle.kts b/smoke-tests/images/spring-boot/build.gradle.kts index e96bc5943e11..e9b8ffdea849 100644 --- a/smoke-tests/images/spring-boot/build.gradle.kts +++ b/smoke-tests/images/spring-boot/build.gradle.kts @@ -5,12 +5,12 @@ plugins { id("otel.java-conventions") id("com.google.cloud.tools.jib") - id("org.springframework.boot") version "2.7.15" + id("org.springframework.boot") version "2.7.16" } dependencies { implementation(platform("io.opentelemetry:opentelemetry-bom:1.0.0")) - implementation(platform("org.springframework.boot:spring-boot-dependencies:2.7.15")) + implementation(platform("org.springframework.boot:spring-boot-dependencies:2.7.16")) implementation("io.opentelemetry:opentelemetry-api") implementation(project(":instrumentation-annotations"))