Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/spring-boot-2-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
springboot-version: [ '2.4.13', '2.5.15', '2.6.15', '2.7.0', '2.7.18' ]
springboot-version: [ '2.7.0', '2.7.18' ]

name: Spring Boot ${{ matrix.springboot-version }}
env:
Expand Down
63 changes: 20 additions & 43 deletions sentry-spring-boot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ tasks.named<KotlinCompile>("compileKotlin") {

// Spring scans the integration test apps' own bytecode with its repackaged ASM at startup, and
// the ASM in Spring before 5.3.26 fails on class files as new as the toolchain's: "Unsupported
// class file major version 65". In the Spring Boot 2.x matrix, 2.4.13 (Spring 5.3.13) reads up
// to Java 18 and 2.7.0 (Spring 5.3.20) up to Java 19, so the suites target 17. Remove this once
// the matrix drops 2.4.13 and moves 2.7.0 to 2.7.10 or later.
// class file major version 65". The Spring Boot 2.x matrix's 2.7.0 (Spring 5.3.20) reads up to
// Java 19, so the suites target 17. Remove this once the matrix moves 2.7.0 to 2.7.10 or later.
// The suites are Kotlin only. Their Java tasks keep the toolchain's level, because it decides
// which Java version their classpaths ask for, and sentry-test-support needs the toolchain's.
tasks
Expand Down Expand Up @@ -137,13 +136,6 @@ tasks.jar {
}
}

// Spring Boot supports GraphQL only from 2.7, and its Kafka auto-configuration needs 2.7 for the
// spring-kafka version Sentry integrates with. The Spring Boot 2 matrix also covers older versions.
val bootSupportsGraphqlAndKafka =
libs.versions.springboot2.get().split(".").let { (major, minor) ->
major.toInt() > 2 || minor.toInt() >= 7
}

// The OpenTelemetry agent tests run this app in a child JVM, on its own classpath like a real app
// with the agent attached, rather than on the test's classpath.
val agentFixture = sourceSets.create("agentFixture")
Expand All @@ -164,20 +156,18 @@ dependencies {
"agentFixtureImplementation"(platform(libs.springboot2.bom))
"agentFixtureImplementation"(projects.sentrySpringBootStarter)
"agentFixtureImplementation"(projects.sentryAsyncProfiler)
"agentFixtureImplementation"(projects.sentryGraphql)
"agentFixtureImplementation"(projects.sentryJdbc)
"agentFixtureImplementation"(projects.sentryKafka)
"agentFixtureImplementation"(projects.sentryLogback)
"agentFixtureImplementation"(kotlin(Config.kotlinStdLib))
"agentFixtureImplementation"(libs.otel)
"agentFixtureImplementation"(libs.springboot.starter.graphql)
"agentFixtureImplementation"(libs.springboot.starter.jdbc)
"agentFixtureImplementation"(libs.springboot.starter.web)
"agentFixtureImplementation"(libs.springboot.starter.webflux)
"agentFixtureImplementation"(libs.spring.kafka2)
"agentFixtureRuntimeOnly"(libs.hsqldb)
if (bootSupportsGraphqlAndKafka) {
"agentFixtureImplementation"(projects.sentryGraphql)
"agentFixtureImplementation"(projects.sentryKafka)
"agentFixtureImplementation"(libs.springboot.starter.graphql)
"agentFixtureImplementation"(libs.spring.kafka2)
}

otelAgentJar(projects.sentryOpentelemetry.sentryOpentelemetryAgent)
}
Expand All @@ -192,7 +182,9 @@ testing {
implementation(platform(libs.springboot2.bom))
implementation(projects.sentrySpringBootStarter)
implementation(projects.sentryAsyncProfiler)
implementation(projects.sentryGraphql)
implementation(projects.sentryJdbc)
implementation(projects.sentryKafka)
implementation(projects.sentryLogback)
implementation(projects.sentryOkhttp)
implementation(projects.sentryTestSupport)
Expand All @@ -202,18 +194,14 @@ testing {
implementation(libs.okhttp)
implementation(libs.springboot.starter.aop)
implementation(libs.springboot.starter.cache)
implementation(libs.springboot.starter.graphql)
implementation(libs.springboot.starter.jdbc)
implementation(libs.springboot.starter.test)
implementation(libs.springboot.starter.web)
implementation(libs.springboot.starter.webflux)
implementation(libs.spring.kafka2)
implementation(libs.spring.kafka2.test)
runtimeOnly(libs.hsqldb)
if (bootSupportsGraphqlAndKafka) {
implementation(projects.sentryGraphql)
implementation(projects.sentryKafka)
implementation(libs.springboot.starter.graphql)
implementation(libs.spring.kafka2)
implementation(libs.spring.kafka2.test)
}
}
}

Expand All @@ -224,16 +212,14 @@ testing {
implementation(platform(libs.springboot2.bom))
implementation(projects.sentrySpringBootStarter)
implementation(projects.sentryAsyncProfiler)
implementation(projects.sentryGraphql)
implementation(projects.sentryLogback)
implementation(projects.sentryTestSupport)
implementation(libs.kotlin.test.junit)
implementation(libs.google.truth)
implementation(libs.springboot.starter.graphql)
implementation(libs.springboot.starter.test)
implementation(libs.springboot.starter.webflux)
if (bootSupportsGraphqlAndKafka) {
implementation(projects.sentryGraphql)
implementation(libs.springboot.starter.graphql)
}
}
}

Expand All @@ -246,24 +232,22 @@ testing {
implementation(projects.sentrySpringBootStarter)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring)
implementation(projects.sentryAsyncProfiler)
implementation(projects.sentryGraphql)
implementation(projects.sentryJdbc)
implementation(projects.sentryKafka)
implementation(projects.sentryLogback)
implementation(projects.sentryTestSupport)
implementation(libs.kotlin.test.junit)
implementation(libs.google.truth)
implementation(libs.springboot.starter.aop)
implementation(libs.springboot.starter.graphql)
implementation(libs.springboot.starter.jdbc)
implementation(libs.springboot.starter.test)
implementation(libs.springboot.starter.web)
implementation(libs.springboot.starter.webflux)
implementation(libs.spring.kafka2)
implementation(libs.spring.kafka2.test)
runtimeOnly(libs.hsqldb)
if (bootSupportsGraphqlAndKafka) {
implementation(projects.sentryGraphql)
implementation(projects.sentryKafka)
implementation(libs.springboot.starter.graphql)
implementation(libs.spring.kafka2)
implementation(libs.spring.kafka2.test)
}
}
}

Expand All @@ -278,9 +262,7 @@ testing {
// For TestRestTemplate. Only the app's JVM runs the agent, so it doesn't trace the tests.
implementation(libs.springboot.starter.test)
implementation(libs.springboot.starter.web)
if (bootSupportsGraphqlAndKafka) {
implementation(libs.spring.kafka2.test)
}
implementation(libs.spring.kafka2.test)
}
targets.all { testTask.configure { runAgentFixture(autoInit = true) } }
}
Expand Down Expand Up @@ -324,10 +306,5 @@ listOf(
"compileIntegrationTestOtelAgentKotlin",
)
.forEach {
tasks.named<KotlinCompile>(it) {
compilerOptions.javaParameters = true
if (!bootSupportsGraphqlAndKafka) {
exclude("**/Graphql*", "**/Greeting*", "**/Kafka*")
}
}
tasks.named<KotlinCompile>(it) { compilerOptions.javaParameters = true }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RestController

const val KAFKA_TOPIC = "sentry-topic"

// Kafka only works with Spring Boot 2.7 and later, so its beans belong to a profile rather than to
// the app most tests share. See KafkaOtelCoexistenceIntegrationTest.
// The beans belong to a profile, so only the app KafkaOtelCoexistenceIntegrationTest starts needs a
// broker.

@RestController
@Profile("kafka")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import org.springframework.web.bind.annotation.RestController

const val KAFKA_TOPIC = "sentry-topic"

// Kafka only works with Spring Boot 2.7 and later, so its beans and broker belong to a profile
// rather than to every test's context. See KafkaIntegrationTest.
// The beans belong to a profile, so only KafkaIntegrationTest's context needs a broker.

@RestController
@Profile("kafka")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.springframework.test.context.TestPropertySource
/**
* A message sent through Kafka is traced on both sides: where it's published and processed.
*
* Unlike the other tests, this one runs its own application context with an in-JVM broker, because
* the shared context has to work on Spring Boot versions without Kafka support.
* Unlike the other tests, this one runs its own application context with an in-JVM broker, so the
* shared context doesn't need one.
*/
@ActiveProfiles("kafka")
@EmbeddedKafka(topics = [KAFKA_TOPIC], bootstrapServersProperty = "spring.kafka.bootstrap-servers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.springframework.kafka.test.EmbeddedKafkaBroker
* With the agent active, OpenTelemetry traces Kafka instead of Sentry's own Spring Kafka
* integration.
*
* Unlike the other tests, this one starts an app of its own, with Kafka and an in-JVM broker. The
* shared app leaves them out, because it has to work on Spring Boot versions without Kafka support.
* Unlike the other tests, this one starts an app of its own, with Kafka and an in-JVM broker, so
* the shared app doesn't need a broker.
*/
class KafkaOtelCoexistenceIntegrationTest : IntegrationTest() {
override val app: AgentApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RestController

const val KAFKA_TOPIC = "sentry-topic"

// Kafka only works with Spring Boot 2.7 and later, so its beans and broker belong to a profile
// rather than to every test's context. See KafkaOtelCoexistenceIntegrationTest.
// The beans belong to a profile, so only KafkaOtelCoexistenceIntegrationTest's context needs a
// broker.

@RestController
@Profile("kafka")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.springframework.test.context.TestPropertySource
/**
* With OpenTelemetry active, it traces Kafka instead of Sentry's own Spring Kafka integration.
*
* Unlike the other tests, this one adds Kafka and an in-JVM broker to its application context. The
* others leave them out, because they have to work on Spring Boot versions without Kafka support.
* Unlike the other tests, this one adds Kafka and an in-JVM broker to its application context, so
* the others don't need a broker.
*/
@ActiveProfiles("kafka")
@EmbeddedKafka(topics = [KAFKA_TOPIC], bootstrapServersProperty = "spring.kafka.bootstrap-servers")
Expand Down
Loading