[Spring Boot] Sentry default settings
Spring BootSentry
It is a software monitoring tool that helps you track, collect, and analyze errors that occur in your application.
Create project
Select the platform on which you want to set up Sentry, and specify the project name and team.
Once a project is created, it will kindly inform you how to set up Sentry on the selected platform.
In this article, set up Sentry in a way that the document(link) tells you.
Check Data Source Name (DSN)
URL used to forward error information from the client to Sentry.
Check the DSN value on the screen that appeared when the project was created, or check the DSN value in the project settings to copy it.
- Settings > Projects > 해당 Project > Client Keys (DSN)
Dependency
This article uses Spring Boot 3 and Kotlin.
build.gradle.kts
kotlin
dependencies {
implementation("io.sentry:sentry-spring-boot-starter-jakarta:7.0.0")
}
Configure
application.yml
yml
sentry:
dsn: "${SENTRY_DSN:sentry-dsn}"
traces-sample-rate: 1.0
exception-resolver-order: -2147483647
- dsn
- Sets the location to send events.
- Create the DSN value copied above using env.
- If this value is not set, it reads the environment variable SENTRY_DSN.
- If the environment variable is also not set, the event is not sent.
- traces-sample-rate
- Controls the amount of transactions sent to Sentry in the event of an error.
- Use numbers between 0 (0%) and 1 (100%).
- For example, if you set 0.2, about 20% will be recorded and sent.
- exception-resolver-order
- Set the order of exception resolution programs. (Note)
- When set to -2147483647(org.springframework.core.Ordered#HIGHEST_PRECEDENCE), errors handled by the Spring Exception Handler are not sent to Sentry.
- For example, exceptions handled by try-catch are not passed to Sentry.
kotlin
try {
throw RuntimeException() // It is not delivered to Sentry.
} catch (e: Exception) {
throw CustomException() // It is delivered to Sentry.
}
Monitoring
If Spring Boot fails at the end of setup
Error information is collected by Sentry.
You'll also get a notification from the email you signed up for.
If necessary, you can also set up Slack to receive notifications.
Setting Timezone
Top left team name > User settings > Account Details > Timezone
Sentry Timezone is UTC by default. Changing to your local country allows you to view it conveniently without calculating the time.
Reference
https://docs.sentry.io/product/