https://www.notion.so/Monitor-Spring-Boot-Application-30e77904ca3241829eafae2f2d96a196
bookmark
Host Your Sentry
1
2
3
| git clone https://github.com/getsentry/onpremise.git
cd onpremise
./install.sh
|
Once your Sentry is ready, you need to create your project with Spring Boot or Java platform in your Sentry.
Set up Spring Boot Application
Get Started
1
2
3
4
5
| <dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
<version>3.1.1</version>
</dependency>
|
1
| sentry.dsn=https://key@host/id
|
Who send the exception?
You can use SentryUserProvider to build a Java Bean:
1
2
3
4
5
6
7
8
9
10
11
12
| @Bean
public SentryUserProvider sentryUserProvider(){
return () -> {
// TODO: get your current user
User user = new User();
user.setId("userId");
user.setUsername("Bendy");
user.setEmail("zb@bndy.net");
return user;
};
}
|
1
2
3
4
5
6
7
| @Bean
public SentryOptions.BeforeSendCallback beforeSendCallback(){
return (event, hint) -> {
event.setTag("name","zhangsan");
return event;
};
}
|
Integration with Logback
1
2
3
4
5
| <dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-logback</artifactId>
<version>3.1.1</version>
</dependency>
|
1
2
3
4
5
6
7
8
9
| @RestController
public class HelloController {
private static Logger logger = LoggerFactory.getLogger(HelloController.class);
@RequestMapping("/")
public void test(){
logger.error("Logback error!");
}
}
|