diff --git a/src/main/java/com/server/bbo_gak/global/config/sentry/SentryConfig.java b/src/main/java/com/server/bbo_gak/global/config/sentry/SentryConfig.java new file mode 100644 index 0000000..93c22ac --- /dev/null +++ b/src/main/java/com/server/bbo_gak/global/config/sentry/SentryConfig.java @@ -0,0 +1,30 @@ +package com.server.bbo_gak.global.config.sentry; + +import com.server.bbo_gak.global.error.exception.BusinessException; +import io.sentry.Sentry; +import io.sentry.SentryOptions; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SentryConfig { + + @Value("${sentry.dsn}") + private String dsn; + + @Bean + public Sentry.OptionsConfiguration sentryOptions() { + return options -> { + options.setDsn(dsn); + + options.setBeforeSend((event, hint) -> { + // 특정 예외 필터링 로직 + if (event.getThrowable() != null && event.getThrowable() instanceof BusinessException) { + return null; // 이 이벤트는 Sentry로 전송되지 않음 + } + return event; // 필터링하지 않을 경우, 이벤트 반환 + }); + }; + } +} diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 142acab..e600dc5 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -46,4 +46,9 @@ google: scheduler: thread: pool: - size: 2 \ No newline at end of file + size: 2 + +sentry: + dsn: https://b0e61ee9ddb2c12240759111df8b607c@o4505869811908608.ingest.us.sentry.io/4507831077240832 + exception-resolver-order: -2147483647 + tracesSampleRate: 1.0 \ No newline at end of file