diff --git a/back/build.gradle.kts b/back/build.gradle.kts index 8f5cd7bd..7a9978ce 100644 --- a/back/build.gradle.kts +++ b/back/build.gradle.kts @@ -67,6 +67,9 @@ dependencies { implementation ("org.springframework.kafka:spring-kafka") runtimeOnly("com.mysql:mysql-connector-j") + + // Sentry + implementation("io.sentry:sentry-spring-boot-starter-jakarta:8.19.1") } tasks.withType { diff --git a/back/src/main/java/com/back/global/security/CustomAuthenticationFilter.java b/back/src/main/java/com/back/global/security/CustomAuthenticationFilter.java index 73b83ad8..08798b8b 100644 --- a/back/src/main/java/com/back/global/security/CustomAuthenticationFilter.java +++ b/back/src/main/java/com/back/global/security/CustomAuthenticationFilter.java @@ -6,6 +6,7 @@ import com.back.global.rq.Rq; import com.back.global.rsData.RsData; import com.back.standard.util.Ut; +import io.sentry.Sentry; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; @@ -36,8 +38,9 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse try { work(request, response, filterChain); - } catch (Exception e) { + } catch (AuthenticationException e) { log.error("CustomAuthenticationFilter에서 예외 발생: ",e); //401 에러로 빠지는거 추적 가능 + Sentry.captureException(e); RsData rsData = new RsData<>("401-1", "인증 오류가 발생했습니다."); response.setContentType("application/json;charset=UTF-8"); response.setStatus(rsData.statusCode()); diff --git a/back/src/main/resources/application.yml b/back/src/main/resources/application.yml index 9109e957..d4c25cf4 100644 --- a/back/src/main/resources/application.yml +++ b/back/src/main/resources/application.yml @@ -2,6 +2,12 @@ server: port: 8080 forward-headers-strategy: native +sentry: + dsn: https://2c0d2da223ce1abb9fa4ed3faaf01955@o4510117752471552.ingest.us.sentry.io/4510118514589696 + traces-sample-rate: 1.0 + send-default-pii: true + + spring: application: name: back