KO EN

[Spring Boot] Sentry default settings

by 민갤

Back End /

Sentry

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.

 캡처 2023-12-14 085740.png

Screen at initial creation

 캡처 2023-12-14 085805.png

Select Spring Boot. Scroll down to set the project name.

 캡처 2023-12-14 085842.png

How to set up Spring Boot

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)
 캡처 2023-12-14 103444.png

DSN Copy

Dependency

This article uses Spring Boot 3 and Kotlin.

build.gradle.kts

dependencies {
    implementation("io.sentry:sentry-spring-boot-starter-jakarta:7.0.0")
}

Configure

application.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.
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

 캡처 2023-12-14 110158.png

Spring Boot Error

Error information is collected by Sentry.

 캡처 2023-12-14 110140.png

Sentry Issue

You'll also get a notification from the email you signed up for.

 캡처 2023-12-14 115625.png

Email Sentry Issue

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.

 캡처 2023-12-14 120610.png

Setting Timezone

Reference

https://docs.sentry.io/product/

Author

민갤

민갤

Back-End Developer

꾸잉꾸잉하고 웁니다.

로그인

디코에 오신 것을 환영해요!
전문가들의 수많은 아티클 창고 🤓