Skip to content

Commit 9f39058

Browse files
authored
Document Spring Boot 4 (#15576)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR *Tell us what you're changing and why. If your PR **resolves an issue**, please link it so it closes automatically.* ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 087b7ec commit 9f39058

File tree

15 files changed

+793
-7
lines changed

15 files changed

+793
-7
lines changed

docs/platforms/java/common/async/index.mdx

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ class AsyncWebMvcConfiguration implements WebMvcConfigurer {
6565
}
6666
```
6767

68+
```java {tabTitle:Java (Spring 7)}
69+
import org.springframework.context.annotation.Configuration;
70+
import org.springframework.core.task.AsyncTaskExecutor;
71+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
72+
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
73+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
74+
75+
import io.sentry.spring7.SentryTaskDecorator;
76+
77+
@Configuration
78+
class AsyncWebMvcConfiguration implements WebMvcConfigurer {
79+
80+
@Override
81+
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
82+
configurer.setTaskExecutor(asyncExecutor());
83+
}
84+
85+
private AsyncTaskExecutor asyncExecutor() {
86+
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
87+
executor.setTaskDecorator(new SentryTaskDecorator());
88+
executor.initialize();
89+
return executor;
90+
}
91+
}
92+
```
93+
6894
```kotlin {tabTitle:Kotlin (Spring 5)}
6995
import org.springframework.context.annotation.Configuration
7096
import org.springframework.core.task.AsyncTaskExecutor
@@ -113,6 +139,30 @@ class AsyncWebMvcConfiguration : WebMvcConfigurer {
113139
}
114140
```
115141

142+
```kotlin {tabTitle:Kotlin (Spring 7)}
143+
import org.springframework.context.annotation.Configuration
144+
import org.springframework.core.task.AsyncTaskExecutor
145+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
146+
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
147+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
148+
149+
import io.sentry.spring7.SentryTaskDecorator
150+
151+
@Configuration
152+
class AsyncWebMvcConfiguration : WebMvcConfigurer {
153+
override fun configureAsyncSupport(configurer: AsyncSupportConfigurer) {
154+
configurer.setTaskExecutor(asyncExecutor())
155+
}
156+
157+
private fun asyncExecutor(): AsyncTaskExecutor {
158+
val executor = ThreadPoolTaskExecutor()
159+
executor.setTaskDecorator(SentryTaskDecorator())
160+
executor.initialize()
161+
return executor
162+
}
163+
}
164+
```
165+
116166
<PlatformSection supported={["java.spring-boot"]}>
117167

118168
Alternatively, if there is a single bean of type `TaskDecorator` in the context, instead of custom `WebMvcConfigurer`, it is enough to create a `SentryTaskDecorator` bean.
@@ -149,6 +199,22 @@ class SentryConfig {
149199
}
150200
```
151201

202+
```java {tabTitle:Java (Spring 7)}
203+
import org.springframework.context.annotation.Bean;
204+
import org.springframework.context.annotation.Configuration;
205+
206+
import io.sentry.spring7.SentryTaskDecorator;
207+
208+
@Configuration
209+
class SentryConfig {
210+
211+
@Bean
212+
public SentryTaskDecorator sentryTaskDecorator() {
213+
return new SentryTaskDecorator();
214+
}
215+
}
216+
```
217+
152218
```kotlin {tabTitle:Kotlin (Spring 5)}
153219
import org.springframework.context.annotation.Bean
154220
import org.springframework.context.annotation.Configuration
@@ -177,6 +243,20 @@ class SentryConfig {
177243
}
178244
```
179245

246+
```kotlin {tabTitle:Kotlin (Spring 7)}
247+
import org.springframework.context.annotation.Bean
248+
import org.springframework.context.annotation.Configuration
249+
250+
import io.sentry.spring7.SentryTaskDecorator
251+
252+
@Configuration
253+
class SentryConfig {
254+
255+
@Bean
256+
fun sentryTaskDecorator() = SentryTaskDecorator()
257+
}
258+
```
259+
180260
</PlatformSection>
181261

182262
## Configuring @Async Methods Task Executor
@@ -225,6 +305,27 @@ class AsyncMethodConfiguration extends AsyncConfigurerSupport {
225305
}
226306
```
227307

308+
```java {tabTitle:Java (Spring 7)}
309+
import org.springframework.context.annotation.Configuration;
310+
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
311+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
312+
313+
import io.sentry.spring7.SentryTaskDecorator;
314+
315+
import java.util.concurrent.Executor;
316+
317+
@Configuration
318+
class AsyncMethodConfiguration extends AsyncConfigurerSupport {
319+
@Override
320+
public Executor getAsyncExecutor() {
321+
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
322+
executor.setTaskDecorator(new SentryTaskDecorator());
323+
executor.initialize();
324+
return executor;
325+
}
326+
}
327+
```
328+
228329
```kotlin {tabTitle:Kotlin (Spring 5)}
229330
import org.springframework.context.annotation.Configuration
230331
import org.springframework.scheduling.annotation.AsyncConfigurerSupport
@@ -264,3 +365,23 @@ class AsyncMethodConfiguration : AsyncConfigurerSupport() {
264365
}
265366
}
266367
```
368+
369+
```kotlin {tabTitle:Kotlin (Spring 7)}
370+
import org.springframework.context.annotation.Configuration
371+
import org.springframework.scheduling.annotation.AsyncConfigurerSupport
372+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
373+
374+
import io.sentry.spring7.SentryTaskDecorator
375+
376+
import java.util.concurrent.Executor
377+
378+
@Configuration
379+
class AsyncMethodConfiguration : AsyncConfigurerSupport() {
380+
override fun getAsyncExecutor(): Executor {
381+
val executor = ThreadPoolTaskExecutor()
382+
executor.setTaskDecorator(SentryTaskDecorator())
383+
executor.initialize()
384+
return executor
385+
}
386+
}
387+
```

docs/platforms/java/guides/spring-boot/record-user.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ class CustomSentryUserProvider implements SentryUserProvider {
5757
}
5858
```
5959

60+
```java {tabTitle:Java (Spring Boot 4)}
61+
import org.springframework.stereotype.Component;
62+
import io.sentry.protocol.User;
63+
import io.sentry.spring7.SentryUserProvider;
64+
65+
@Component
66+
class CustomSentryUserProvider implements SentryUserProvider {
67+
public User provideUser() {
68+
User user = new User();
69+
// ... set user information
70+
return user
71+
}
72+
}
73+
```
74+
6075
```kotlin {tabTitle:Kotlin (Spring Boot 2)}
6176
import org.springframework.stereotype.Component
6277
import io.sentry.protocol.User
@@ -86,3 +101,18 @@ class CustomSentryUserProvider : SentryUserProvider {
86101
}
87102
}
88103
```
104+
105+
```kotlin {tabTitle:Kotlin (Spring Boot 4)}
106+
import org.springframework.stereotype.Component
107+
import io.sentry.protocol.User
108+
import io.sentry.spring7.SentryUserProvider
109+
110+
@Component
111+
class CustomSentryUserProvider : SentryUserProvider {
112+
override fun provideUser(): User? {
113+
val user = User()
114+
// ... set user information
115+
return user
116+
}
117+
}
118+
```

0 commit comments

Comments
 (0)