Skip to content

Duplicate Spring Boot 2/3 starter and autoconfigure modules for Spring Boot 4 #14416

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions .fossa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ targets:
- type: gradle
path: ./
target: ':instrumentation:spring:spring-boot-autoconfigure'
- type: gradle
path: ./
target: ':instrumentation:spring:spring-boot-autoconfigure-4.0'
- type: gradle
path: ./
target: ':instrumentation:spymemcached-2.12:javaagent'
Expand Down Expand Up @@ -937,6 +940,9 @@ targets:
- type: gradle
path: ./
target: ':instrumentation:spring:starters:spring-boot-starter'
- type: gradle
path: ./
target: ':instrumentation:spring:starters:spring-boot-starter-4.0'
- type: gradle
path: ./
target: ':instrumentation:spring:starters:zipkin-spring-boot-starter'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-4.0-2.19.0-SNAPSHOT.jar against
+++ NEW CLASS: PUBLIC(+) io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration (not serializable)
+++ CLASS FILE FORMAT VERSION: 61.0 <- n.a.
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW CONSTRUCTOR: PUBLIC(+) OpenTelemetryAutoConfiguration()
+++ NEW ANNOTATION: org.springframework.context.annotation.Configuration
+++ NEW ANNOTATION: org.springframework.boot.context.properties.EnableConfigurationProperties
+++ NEW ELEMENT: value=io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtlpExporterProperties,io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelResourceProperties,io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelSpringProperties (+)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OpenTelemetry Spring Auto-Configuration

Auto-configures OpenTelemetry instrumentation for [spring-web](../spring-web/spring-web-3.1/library)
, [spring-webmvc](../spring-webmvc/spring-webmvc-5.3/library),
and [spring-webflux](../spring-webflux/spring-webflux-5.3/library). Leverages Spring Aspect Oriented
Programming, dependency injection, and bean post-processing to trace spring applications. To include
all features listed below use the [opentelemetry-spring-boot-starter](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/).

Documentation for OpenTelemetry Spring Auto-Configuration can be found [here](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/out-of-the-box-instrumentation/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
plugins {
id("otel.library-instrumentation")
id("otel.japicmp-conventions")
}

base.archivesName.set("opentelemetry-spring-boot-autoconfigure-4.0")
group = "io.opentelemetry.instrumentation"

val springBootVersion = "4.0.0-M1"

// r2dbc-proxy is shadowed to prevent org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration
// from being loaded by Spring Boot (by the presence of META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider) - even if the user doesn't want to use R2DBC.
sourceSets {
main {
val shadedDep = project(":instrumentation:r2dbc-1.0:library-instrumentation-shaded")
output.dir(
shadedDep.file("build/extracted/shadow-spring"),
"builtBy" to ":instrumentation:r2dbc-1.0:library-instrumentation-shaded:extractShadowJarSpring",
)
}
}

dependencies {
compileOnly("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
implementation("javax.validation:validation-api")

implementation(project(":instrumentation-annotations-support"))
implementation(project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"))
implementation(project(":instrumentation:mongo:mongo-3.1:library"))
compileOnly(project(path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", configuration = "shadow"))
implementation(project(":instrumentation:spring:spring-kafka-2.7:library"))
implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library"))
implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-5.3:library"))
compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0")
implementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library"))
implementation(project(":instrumentation:micrometer:micrometer-1.5:library"))
implementation(project(":instrumentation:log4j:log4j-appender-2.17:library"))
compileOnly("org.apache.logging.log4j:log4j-core:2.17.0")
implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
implementation(project(":instrumentation:logback:logback-mdc-1.0:library"))
compileOnly("ch.qos.logback:logback-classic:1.0.0")
implementation(project(":instrumentation:jdbc:library"))
implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java8:library"))
implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java17:library"))
compileOnly("org.springframework.boot:spring-boot-starter-kafka:$springBootVersion")
compileOnly("org.springframework.boot:spring-boot-starter-mongodb:$springBootVersion")
compileOnly("org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion")

library("org.springframework.kafka:spring-kafka:2.9.0")
library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion")
library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion")
library("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
library("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion")
library("org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion")
library("org.springframework.boot:spring-boot-starter-data-r2dbc:$springBootVersion")

implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
implementation(project(":sdk-autoconfigure-support"))
compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators")
compileOnly("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
compileOnly("io.opentelemetry:opentelemetry-exporter-logging")
compileOnly("io.opentelemetry:opentelemetry-exporter-otlp")
compileOnly("io.opentelemetry:opentelemetry-exporter-zipkin")
compileOnly(project(":instrumentation-annotations"))

compileOnly(project(":instrumentation:resources:library"))
annotationProcessor("com.google.auto.service:auto-service")
compileOnly("com.google.auto.service:auto-service-annotations")

testLibrary("org.springframework.boot:spring-boot-starter-test:$springBootVersion") {
exclude("org.junit.vintage", "junit-vintage-engine")
}
// testImplementation("javax.servlet:javax.servlet-api:3.1.0")
testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0")
testRuntimeOnly("com.h2database:h2:1.4.197")
testRuntimeOnly("io.r2dbc:r2dbc-h2:1.0.0.RELEASE")

testImplementation(project(":testing-common"))
testImplementation("io.opentelemetry:opentelemetry-sdk")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation(project(":instrumentation:resources:library"))
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
testImplementation("io.opentelemetry:opentelemetry-exporter-logging")
testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
testImplementation("io.opentelemetry:opentelemetry-exporter-zipkin")
testImplementation(project(":instrumentation-annotations"))

implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"))
compileOnly("org.springframework.boot:spring-boot-starter-restclient:$springBootVersion")
}

val latestDepTest = findProperty("testLatestDeps") as Boolean

// spring 6 (spring boot 3) requires java 17
if (latestDepTest) {
otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}
}

val testJavaVersion = gradle.startParameter.projectProperties["testJavaVersion"]?.let(JavaVersion::toVersion)

testing {
suites {
val testLogbackAppender by registering(JvmTestSuite::class) {
dependencies {
implementation(project())
implementation(project(":testing-common"))
implementation("io.opentelemetry:opentelemetry-sdk")
implementation("io.opentelemetry:opentelemetry-sdk-testing")
implementation("org.mockito:mockito-inline")
implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")

implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
implementation(project(":instrumentation:logback:logback-mdc-1.0:library"))
// using the same versions as in the spring-boot-autoconfigure
implementation("ch.qos.logback:logback-classic") {
version {
strictly("1.2.11")
}
}
implementation("org.slf4j:slf4j-api") {
version {
strictly("1.7.32")
}
}
}
}

val testLogbackMissing by registering(JvmTestSuite::class) {
dependencies {
implementation(project())
implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")

implementation("org.slf4j:slf4j-api") {
version {
strictly("1.7.32")
}
}
}
}
}
}

configurations.configureEach {
if (name.contains("testLogbackMissing")) {
exclude("ch.qos.logback", "logback-classic")
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// options.release.set(17)
}

otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}

tasks {
compileTestJava {
options.compilerArgs.add("-parameters")
}

withType<Test>().configureEach {
systemProperty("testLatestDeps", latestDepTest)

// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testing.suites)
dependsOn(testStableSemconv)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
otel.stable=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description: >
This instrumentation auto-configures OpenTelemetry instrumentation for spring-web, spring-webmvc,
and spring-webflux to instrument Spring Boot applications. It does not produce telemetry on its
own. This instrumentation is mostly used as part of the Spring Boot starter.
Loading
Loading