[#9] feat: 4xx/5xx 에러 Discord 알림 구현 - #12
Merged
Merged
Conversation
- 테스트 실행 시 루트에 생성되는 spy.log가 실수로 커밋되지 않도록 무시 목록에 추가 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
운영 중 발생하는 에러 응답을 Discord 채널로 알려 모니터링/경고를 돕는다.
현재는 4xx/5xx 에러 알림만 연결하며, 배치·모니터링 등은 DiscordSender를 재사용해 확장한다.
- common/discord에 알림 인프라 추가
- DiscordSender 인터페이스 + 프로필별 구현(로컬/테스트 LogDiscordSender, 운영/개발 WebhookDiscordSender)
- WebhookDiscordSender는 java.net.http.HttpClient.sendAsync로 비동기 전송해 요청 스레드를 막지 않고,
직렬화/네트워크 실패와 비-2xx 응답(429 등)을 로깅만 하고 삼킴(실패 안전)
- DiscordAlertNotifier가 enabled/min-status로 발송을 게이트하고 메시지를 포맷(5xx는 스택트레이스 첨부)
- GlobalExceptionHandler의 모든 에러 핸들러에서 notifyError를 호출해 4xx/5xx 응답 시 알림 트리거
(알림 실패는 응답에 영향 없음, 응답 상태/바디 불변)
- application.yml에 discord 설정 추가(webhook-url은 환경변수로 주입, alert.enabled 기본 false, min-status 기본 400)
- 기존 EmailSender 패턴(인터페이스 + @Profile 분리)과 일관
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📄 작업 내용
common/discord알림 인프라 추가 (기존EmailSender프로필 패턴과 일관)DiscordSender인터페이스 + 프로필별 구현:LogDiscordSender(local/test),WebhookDiscordSender(dev/prod)WebhookDiscordSender는HttpClient.sendAsync로 비동기 전송 — 요청 스레드 비차단, 직렬화/네트워크 실패·비-2xx 응답(429 등)은 로깅만(실패 안전)DiscordAlertNotifier가alert.enabled/alert.min-status로 발송을 게이트하고 메시지 포맷 (5xx는 스택트레이스 첨부)GlobalExceptionHandler의 모든 에러 핸들러에서notifyError(...)호출 → 4xx/5xx 응답 시 알림 트리거 (응답 상태/바디 불변, 알림 실패가 응답에 영향 없음)application.yml에discord.*설정 추가 (webhook-url은 환경변수 주입,alert.enabled기본 false,alert.min-status기본 400)DiscordSender재사용으로 확장 가능. 현재는 요구대로 4xx/5xx 에러 알림만 연결✅ PR 유형
🧪 테스트 내용
🙋🏻 참고 사항
DISCORD_WEBHOOK_URL(secret) 주입 +DISCORD_ALERT_ENABLED=true필요. 코드/설정에 실제 URL 하드코딩 없음.min-status: 400이라 모든 검증 실패/404도 알림됩니다(요구사항대로). 노이즈를 줄이려면 운영에서discord.alert.min-status: 500권장.spring-cloud-openfeign의존성 없이 구현, REST 엔드포인트 없음(알림은 내부 트리거).🔗 관련 이슈
resolved: #9