-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: dev/prod 별 센트리 dsn, environment, servername 설정 * chore: logback 전용 Sentry 의존성 추가 * feat: Sentry logback 기능 추가 * feat: Sentry 속성을 주입하는 SentryConfig 추가 * feat: Sentry Exception 테스트용 임시 API 추가 * chore: slack webhook 의존성 주입 * chore: slack 웹훅에 사용될 환경변수 설정 * chore: 에러감지 시 Slack으로 Sentry 주소를 보내주도록 구현 * chore: test용 yml파일에 변경사항 업데이트 * feat: IOException Handler 메서드 추가
- Loading branch information
Showing
10 changed files
with
177 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
main/src/main/java/org/sopt/makers/crew/main/global/config/SentryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.sopt.makers.crew.main.global.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import io.sentry.Sentry; | ||
import jakarta.annotation.PostConstruct; | ||
|
||
@Configuration | ||
public class SentryConfig { | ||
|
||
@Value("${sentry.dsn}") | ||
private String sentryDsn; | ||
|
||
@Value("${sentry.environment}") | ||
private String environment; | ||
|
||
@Value("${sentry.servername}") | ||
private String serverName; | ||
|
||
@PostConstruct | ||
public void initSentry() { | ||
Sentry.init(options -> { | ||
options.setDsn(sentryDsn); | ||
options.setEnvironment(environment); | ||
options.setServerName(serverName); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
main/src/main/java/org/sopt/makers/crew/main/global/sentry/SentryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.sopt.makers.crew.main.global.sentry; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.sentry.Sentry; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/sentry") | ||
public class SentryController { | ||
|
||
@GetMapping | ||
public ResponseEntity<String> testSentry() { // prod에서 테스트 후 삭제 | ||
try { | ||
throw new Exception("This is a test exception for Sentry."); | ||
} catch (Exception e) { | ||
Sentry.captureException(e); | ||
log.error("Exception captured in Sentry", e); | ||
return ResponseEntity.status(500).body("Exception captured in Sentry"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters