Skip to content

Commit 89b4584

Browse files
committed
Sentry 설정 및 Exception 핸들링 수정
1 parent 99cf069 commit 89b4584

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

back/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ dependencies {
6767
implementation ("org.springframework.kafka:spring-kafka")
6868

6969
runtimeOnly("com.mysql:mysql-connector-j")
70+
71+
// Sentry
72+
implementation("io.sentry:sentry-spring-boot-starter-jakarta:8.19.1")
7073
}
7174

7275
tasks.withType<Test> {

back/src/main/java/com/back/global/security/CustomAuthenticationFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.back.global.rq.Rq;
77
import com.back.global.rsData.RsData;
88
import com.back.standard.util.Ut;
9+
import io.sentry.Sentry;
910
import jakarta.servlet.FilterChain;
1011
import jakarta.servlet.ServletException;
1112
import jakarta.servlet.http.HttpServletRequest;
@@ -14,6 +15,7 @@
1415
import lombok.extern.slf4j.Slf4j;
1516
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
1617
import org.springframework.security.core.Authentication;
18+
import org.springframework.security.core.AuthenticationException;
1719
import org.springframework.security.core.authority.SimpleGrantedAuthority;
1820
import org.springframework.security.core.context.SecurityContextHolder;
1921
import org.springframework.stereotype.Component;
@@ -36,8 +38,9 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
3638

3739
try {
3840
work(request, response, filterChain);
39-
} catch (Exception e) {
41+
} catch (AuthenticationException e) {
4042
log.error("CustomAuthenticationFilter에서 예외 발생: ",e); //401 에러로 빠지는거 추적 가능
43+
Sentry.captureException(e);
4144
RsData<Void> rsData = new RsData<>("401-1", "인증 오류가 발생했습니다.");
4245
response.setContentType("application/json;charset=UTF-8");
4346
response.setStatus(rsData.statusCode());

back/src/main/resources/application.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ server:
22
port: 8080
33
forward-headers-strategy: native
44

5+
sentry:
6+
dsn: https://2c0d2da223ce1abb9fa4ed3faaf01955@o4510117752471552.ingest.us.sentry.io/4510118514589696
7+
traces-sample-rate: 1.0
8+
send-default-pii: true
9+
10+
511
spring:
612
application:
713
name: back

0 commit comments

Comments
 (0)