Skip to content

Commit e7a97e5

Browse files
committed
Add new modules for Spring 7 and Spring Boot 4
1 parent bc1e990 commit e7a97e5

File tree

240 files changed

+18257
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+18257
-0
lines changed

.craft.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ targets:
1919
maven:io.sentry:sentry:
2020
maven:io.sentry:sentry-spring:
2121
maven:io.sentry:sentry-spring-jakarta:
22+
# maven:io.sentry:sentry-spring-7:
2223
maven:io.sentry:sentry-spring-boot:
2324
maven:io.sentry:sentry-spring-boot-jakarta:
2425
maven:io.sentry:sentry-spring-boot-starter:
2526
maven:io.sentry:sentry-spring-boot-starter-jakarta:
27+
# maven:io.sentry:sentry-spring-boot-4:
28+
# maven:io.sentry:sentry-spring-boot-4-starter:
2629
maven:io.sentry:sentry-servlet:
2730
maven:io.sentry:sentry-servlet-jakarta:
2831
maven:io.sentry:sentry-logback:

.github/ISSUE_TEMPLATE/bug_report_java.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ body:
2424
- sentry-spring-boot-jakarta
2525
- sentry-spring-boot-starter
2626
- sentry-spring-boot-starter-jakarta
27+
- sentry-spring-boot-4
28+
- sentry-spring-boot-4-starter
2729
- sentry-spring
2830
- sentry-spring-jakarta
31+
- sentry-spring-7
2932
- sentry-logback
3033
- sentry-log4j2
3134
- sentry-graphql

.github/workflows/system-tests-backend.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ jobs:
5454
- sample: "sentry-samples-console"
5555
agent: "false"
5656
agent-auto-init: "true"
57+
- sample: "sentry-samples-spring-boot-jakarta"
58+
agent: "false"
59+
agent-auto-init: "true"
60+
- sample: "sentry-samples-spring-boot-4-webflux"
61+
agent: "false"
62+
agent-auto-init: "true"
63+
- sample: "sentry-samples-spring-boot-4-opentelemetry-noagent"
64+
agent: "false"
65+
agent-auto-init: "true"
66+
- sample: "sentry-samples-spring-boot-4-opentelemetry"
67+
agent: "true"
68+
agent-auto-init: "true"
69+
- sample: "sentry-samples-spring-boot-4-opentelemetry"
70+
agent: "true"
71+
agent-auto-init: "false"
5772
steps:
5873
- uses: actions/checkout@v4
5974
with:

build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ apiValidation {
6161
"sentry-samples-servlet",
6262
"sentry-samples-spring",
6363
"sentry-samples-spring-jakarta",
64+
"sentry-samples-spring-7",
6465
"sentry-samples-spring-boot",
6566
"sentry-samples-spring-boot-opentelemetry",
6667
"sentry-samples-spring-boot-opentelemetry-noagent",
@@ -69,6 +70,10 @@ apiValidation {
6970
"sentry-samples-spring-boot-jakarta-opentelemetry-noagent",
7071
"sentry-samples-spring-boot-webflux",
7172
"sentry-samples-spring-boot-webflux-jakarta",
73+
"sentry-samples-spring-boot-4",
74+
"sentry-samples-spring-boot-4-opentelemetry",
75+
"sentry-samples-spring-boot-4-opentelemetry-noagent",
76+
"sentry-samples-spring-boot-4-webflux",
7277
"sentry-samples-ktor-client",
7378
"sentry-uitest-android",
7479
"sentry-uitest-android-benchmark",

buildSrc/src/main/java/Config.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ object Config {
5353
val SENTRY_LOG4J2_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.log4j2"
5454
val SENTRY_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring"
5555
val SENTRY_SPRING_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring.jakarta"
56+
val SENTRY_SPRING_7_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-7"
5657
val SENTRY_SPRING_BOOT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot"
5758
val SENTRY_SPRING_BOOT_STARTER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter"
5859
val SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot.jakarta"
5960
val SENTRY_SPRING_BOOT_STARTER_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter.jakarta"
61+
val SENTRY_SPRING_BOOT_4_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-4"
62+
val SENTRY_SPRING_BOOT_4_STARTER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-4-starter"
6063
val SENTRY_OPENTELEMETRY_BOOTSTRAP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.bootstrap"
6164
val SENTRY_OPENTELEMETRY_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.core"
6265
val SENTRY_OPENTELEMETRY_AGENT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agent"

gradle/libs.versions.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ retrofit = "2.9.0"
3030
slf4j = "1.7.30"
3131
springboot2 = "2.7.18"
3232
springboot3 = "3.5.0"
33+
springboot4 = "4.0.0-M1"
3334
# Android
3435
targetSdk = "34"
3536
compileSdk = "34"
@@ -53,6 +54,7 @@ kover = { id = "org.jetbrains.kotlinx.kover", version = "0.7.3" }
5354
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" }
5455
springboot2 = { id = "org.springframework.boot", version.ref = "springboot2" }
5556
springboot3 = { id = "org.springframework.boot", version.ref = "springboot3" }
57+
springboot4 = { id = "org.springframework.boot", version.ref = "springboot4" }
5658
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.0.11.RELEASE" }
5759
gretty = { id = "org.gretty", version = "4.0.0" }
5860

@@ -150,6 +152,18 @@ springboot3-starter-aop = { module = "org.springframework.boot:spring-boot-start
150152
springboot3-starter-security = { module = "org.springframework.boot:spring-boot-starter-security", version.ref = "springboot3" }
151153
springboot3-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "springboot3" }
152154
springboot3-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "springboot3" }
155+
springboot4-otel = { module = "io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter", version.ref = "otelInstrumentation" }
156+
springboot4-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "springboot4" }
157+
springboot4-starter-graphql = { module = "org.springframework.boot:spring-boot-starter-graphql", version.ref = "springboot4" }
158+
springboot4-starter-quartz = { module = "org.springframework.boot:spring-boot-starter-quartz", version.ref = "springboot4" }
159+
springboot4-starter-test = { module = "org.springframework.boot:spring-boot-starter-test", version.ref = "springboot4" }
160+
springboot4-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "springboot4" }
161+
springboot4-starter-websocket = { module = "org.springframework.boot:spring-boot-starter-websocket", version.ref = "springboot4" }
162+
springboot4-starter-webflux = { module = "org.springframework.boot:spring-boot-starter-webflux", version.ref = "springboot4" }
163+
springboot4-starter-aop = { module = "org.springframework.boot:spring-boot-starter-aop", version.ref = "springboot4" }
164+
springboot4-starter-security = { module = "org.springframework.boot:spring-boot-starter-security", version.ref = "springboot4" }
165+
springboot4-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "springboot4" }
166+
springboot4-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "springboot4" }
153167
timber = { module = "com.jakewharton.timber:timber", version = "4.7.1" }
154168

155169
# test libraries
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Sentry Sample Spring 6.0+
2+
3+
Sample application showing how to use Sentry with [Spring](http://spring.io/) from version `6.0` onwards.
4+
5+
## How to run?
6+
7+
To see events triggered in this sample application in your Sentry dashboard, go to `src/main/java/io/sentry/samples/spring/jakarta/SentryConfig.java` and replace the test DSN with your own DSN.
8+
9+
Then, execute a command from the module directory:
10+
11+
```
12+
../../gradlew appRun
13+
```
14+
15+
Make an HTTP request that will trigger events:
16+
17+
```
18+
curl -XPOST --user user:password http://localhost:8080/sentry-samples-spring-jakarta/person/ -H "Content-Type:application/json" -d '{"firstName":"John","lastName":"Smith"}'
19+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import org.jetbrains.kotlin.config.KotlinCompilerVersion
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import org.springframework.boot.gradle.plugin.SpringBootPlugin
4+
5+
plugins {
6+
alias(libs.plugins.springboot4) apply false
7+
alias(libs.plugins.spring.dependency.management)
8+
kotlin("jvm")
9+
alias(libs.plugins.kotlin.spring)
10+
id("war")
11+
alias(libs.plugins.gretty)
12+
}
13+
14+
group = "io.sentry.sample.spring-7"
15+
16+
version = "0.0.1-SNAPSHOT"
17+
18+
java.sourceCompatibility = JavaVersion.VERSION_17
19+
20+
java.targetCompatibility = JavaVersion.VERSION_17
21+
22+
repositories { mavenCentral() }
23+
24+
dependencyManagement { imports { mavenBom(SpringBootPlugin.BOM_COORDINATES) } }
25+
26+
dependencies {
27+
implementation(Config.Libs.springWeb)
28+
implementation(Config.Libs.springAop)
29+
implementation(Config.Libs.aspectj)
30+
implementation(Config.Libs.springSecurityWeb)
31+
implementation(Config.Libs.springSecurityConfig)
32+
implementation(Config.Libs.kotlinReflect)
33+
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
34+
implementation(projects.sentrySpring7)
35+
implementation(projects.sentryLogback)
36+
implementation(libs.jackson.databind)
37+
implementation(libs.logback.classic)
38+
implementation(libs.servlet.jakarta.api)
39+
implementation(libs.slf4j2.api)
40+
testImplementation(libs.springboot.starter.test) {
41+
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
42+
}
43+
}
44+
45+
tasks.withType<Test>().configureEach { useJUnitPlatform() }
46+
47+
tasks.withType<KotlinCompile>().configureEach {
48+
kotlinOptions {
49+
freeCompilerArgs = listOf("-Xjsr305=strict")
50+
jvmTarget = JavaVersion.VERSION_17.toString()
51+
}
52+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.sentry.samples.spring.jakarta;
2+
3+
import io.sentry.IScopes;
4+
import io.sentry.spring.jakarta.SentryUserFilter;
5+
import io.sentry.spring.jakarta.SentryUserProvider;
6+
import java.util.List;
7+
import org.springframework.context.annotation.Bean;
8+
import org.springframework.context.annotation.Configuration;
9+
import org.springframework.context.annotation.Import;
10+
11+
@Configuration
12+
@Import(SentryConfig.class)
13+
public class AppConfig {
14+
15+
@Bean
16+
SentryUserFilter sentryUserFilter(
17+
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
18+
return new SentryUserFilter(scopes, sentryUserProviders);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.sentry.samples.spring.jakarta;
2+
3+
import io.sentry.spring.jakarta.tracing.SentryTracingFilter;
4+
import jakarta.servlet.Filter;
5+
import org.springframework.web.filter.DelegatingFilterProxy;
6+
import org.springframework.web.filter.RequestContextFilter;
7+
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
8+
9+
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
10+
11+
@Override
12+
protected String[] getServletMappings() {
13+
return new String[] {"/*"};
14+
}
15+
16+
@Override
17+
protected Class<?>[] getRootConfigClasses() {
18+
return new Class<?>[] {AppConfig.class, SecurityConfiguration.class};
19+
}
20+
21+
@Override
22+
protected Class<?>[] getServletConfigClasses() {
23+
return new Class<?>[] {WebConfig.class};
24+
}
25+
26+
@Override
27+
protected Filter[] getServletFilters() {
28+
// creates Sentry transactions around incoming HTTP requests
29+
SentryTracingFilter sentryTracingFilter = new SentryTracingFilter();
30+
31+
// filter required by Spring Security
32+
DelegatingFilterProxy springSecurityFilterChain = new DelegatingFilterProxy();
33+
springSecurityFilterChain.setTargetBeanName("springSecurityFilterChain");
34+
// sets request on RequestContextHolder
35+
RequestContextFilter requestContextFilter = new RequestContextFilter();
36+
37+
// sets Sentry user on the scope
38+
DelegatingFilterProxy sentryUserFilterProxy = new DelegatingFilterProxy();
39+
sentryUserFilterProxy.setTargetBeanName("sentryUserFilter");
40+
41+
return new Filter[] {
42+
sentryTracingFilter, springSecurityFilterChain, requestContextFilter, sentryUserFilterProxy
43+
};
44+
}
45+
}

0 commit comments

Comments
 (0)