Skip to content

Commit

Permalink
Merge pull request #126 from depromeet/feature/#125
Browse files Browse the repository at this point in the history
[feat][#125] businessException도 tracing
  • Loading branch information
sejoon00 authored Oct 7, 2024
2 parents 5597a1c + 13a7106 commit 6b0aa39
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/server/bbo_gak/global/TestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.server.bbo_gak.global;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

@GetMapping("/error")
public String generateError() {
throw new RuntimeException("This is a test exception for Sentry!");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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;
Expand All @@ -17,13 +16,8 @@ public class SentryConfig {
public Sentry.OptionsConfiguration<SentryOptions> sentryOptions() {
return options -> {
options.setDsn(dsn);

options.setBeforeSend((event, hint) -> {
// 특정 예외 필터링 로직
if (event.getThrowable() != null && event.getThrowable() instanceof BusinessException) {
return null; // 이 이벤트는 Sentry로 전송되지 않음
}
return event; // 필터링하지 않을 경우, 이벤트 반환
return event;
});
};
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application-datasource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spring:
password: ${MYSQL_PASSWORD}
username: ${MYSQL_USERNAME}
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ scheduler:
sentry:
dsn: ${SENTRY_DSN}
exception-resolver-order: -2147483647
enable-tracing: true
tracesSampleRate: 1.0
debug: true
environment: local

0 comments on commit 6b0aa39

Please sign in to comment.