Skip to content

[FEAT/#487] 커스텀 도메인 메트릭 · 운영 Discord 알림 추가 - #490

Merged
leesumin0526 merged 10 commits into
developfrom
feat/#487-add-domain-metrics
Oct 6, 2026
Merged

leesumin0526 merged 10 commits into
developfrom
feat/#487-add-domain-metrics

Conversation

@leesumin0526

@leesumin0526 leesumin0526 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

close #487

📝작업 내용

HTTP 레이어로 포착되지 않는 비즈니스 이벤트 단위의 커스텀 메트릭 추가, S3 삭제 실패 메트릭 추가, 회원가입 중 UserPaper 동기화 버그 수정, 운영 이벤트 발생/처리 완료 시 Discord 알림 발송.

🔎코드 설명(스크린샷(선택))

커스텀 메트릭 (Micrometer Counter)

메트릭 발생 시점 목적
inquiry.created 문의 등록 성공 문의 접수량 추적
device.token.registered 신규 디바이스 토큰 등록 FCM 토큰 등록 추이 파악
device.token.deleted 디바이스 토큰 삭제 로그아웃/탈퇴 빈도 파악
member.profile.image.s3.delete.failure 프로필 이미지 교체 중 이전 파일 S3 삭제 실패 S3 고아 파일 발생 추적
  • 쓰기 트랜잭션 내 메트릭은 afterCommit 패턴 적용 (롤백 시 카운터 증가 방지)

UserPaper 동기화 버그 수정

  • 기존: syncUserPapersForStudent가 REQUIRED 전파로 회원가입 트랜잭션에 합류 → 동기화 실패 시 회원가입 전체 롤백
  • 수정: REQUIRES_NEW로 별도 트랜잭션 분리 + SignUpServiceImpl에서 try-catch로 예외 흡수 → 동기화 실패해도 회원가입은 성공

Discord 알림 (DiscordNotifier)

이벤트 접수 시:

알림 발송 시점
📬 새 문의가 접수되었습니다 InquiryServiceImpl.create() 커밋 후
🚨 새 신고가 접수되었습니다 ReportServiceImpl.reportContent/reportStudent() 커밋 후
🔔 새 제휴업체/학생회 가입 승인 요청 SignUpServiceImpl.signupPartner/signupAdmin() 커밋 후 (복구 케이스 제외)

처리 완료 시:

알림 발송 시점
💬 문의 답변이 등록되었습니다 BackofficeInquiryServiceImpl.answer() 커밋 후
📋 신고 상태가 변경되었습니다: {상태} BackofficeReportServiceImpl.updateReportStatus() 커밋 후
🗑️ 신고된 콘텐츠가 삭제 처리되었습니다 BackofficeReportServiceImpl.softDeleteReview/Suggestion() 커밋 후
✅ 신고가 기각되었습니다 BackofficeReportServiceImpl.rejectReport() 커밋 후
✅ 제휴업체/학생회 회원가입이 승인되었습니다 BackofficeMemberServiceImpl.approveMember() 커밋 후
❌ 제휴업체/학생회 회원가입이 거절되었습니다 BackofficeMemberServiceImpl.rejectMember() 커밋 후
  • 모두 afterCommit 패턴 적용 (트랜잭션 롤백 시 알림 미발송)
  • webhook URL 미설정 시 자동 skip, 전송 실패 시 warn 로그만 기록

💬고민사항 및 리뷰 요구사항 (Optional)

  • runAfterCommit 헬퍼가 InquiryServiceImpl, BackofficeInquiryServiceImpl, ReportServiceImpl, BackofficeReportServiceImpl, BackofficeMemberServiceImpl, DeviceTokenServiceImpl, SignUpServiceImpl에 각각 중복 선언되어 있음. 공통 유틸로 추출하는 것을 고려할 수 있으나 현재 범위에서는 보류
  • signupBatchPartner는 운영자가 직접 실행하는 배치 작업이므로 Discord 알림 미적용
  • 복구(restore) 케이스는 이미 승인 이력이 있는 계정이므로 가입 승인 대기 알림 미적용

비고 (Optional)

  • Discord 웹훅 URL은 config/prod/application-prod.yml의 discord.webhook.service-alert에 설정
  • 로컬/dev 환경은 해당 키 미설정으로 자동 skip 됨

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ASSU-dev/ASSU_BE/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5006752e-7d16-4177-8cdc-6b4785421a5c
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- InquiryServiceImpl에 inquiry.created Counter 추가 (문의 생성 시 증가)
- StudentServiceImpl에 student.usable.queried Counter 추가 (사용 가능 제휴 조회 시 증가)
- DeviceTokenServiceImpl에 device.token.registered Counter 추가 (신규 토큰 등록 시 증가)
- DeviceTokenServiceImpl에 device.token.deleted Counter 추가 (토큰 비활성화 시 증가)
- 쓰기 트랜잭션 내 카운터는 afterCommit 패턴 적용으로 롤백된 작업 미집계
- student.usable.queried Counter 제거 (조회 횟수 집계 불필요)
- syncUserPapersForStudent에 동기화 결과 로그 추가 (studentId, synced 건수)
- syncUserPapersForStudent를 REQUIRES_NEW 전파로 변경하여 실패 시 독립 롤백
- syncUserPapersForStudent 호출부를 try-catch로 감싸 동기화 실패가 회원가입에 영향 없도록 처리
- 동기화 실패 시 log.error로 studentId와 예외 기록
- DiscordNotifier 컴포넌트 추가 (infra/discord)
- InquiryServiceImpl: 문의 생성 후 afterCommit 시점에 Discord #서비스-알림 채널로 알림 전송
- ProfileImageServiceImpl: 이전 프로필 이미지 S3 삭제 실패 시 member.profile.image.s3.delete.failure 카운터 증가
- config/prod: discord.webhook.service-alert URL 추가
- DiscordNotifier에 sendReportAlert, sendSignupPendingAlert 메서드 추가
- ReportServiceImpl: reportContent/reportStudent 저장 후 afterCommit으로 Discord 알림 발송
- SignUpServiceImpl: signupPartner(제휴업체)/signupAdmin(학생회) 신규 가입 시 afterCommit으로 Discord 알림 발송 (복구 케이스 제외)
- DiscordNotifier에 처리 완료 알림 메서드 6종 추가
- BackofficeInquiryServiceImpl: 문의 답변 완료 시 Discord 알림
- BackofficeReportServiceImpl: 신고 상태 변경·콘텐츠 삭제·기각 시 Discord 알림
- BackofficeMemberServiceImpl: 제휴업체/학생회 가입 승인·거절 시 Discord 알림
- 모두 afterCommit 패턴 적용
@leesumin0526
leesumin0526 force-pushed the feat/#487-add-domain-metrics branch from 17e40d5 to 9e50aae Compare October 5, 2026 09:53
@leesumin0526 leesumin0526 self-assigned this Oct 5, 2026
Comment thread src/main/java/com/assu/server/infra/discord/DiscordNotifier.java
- 알림 종류별 메서드 제거 후 send(String)을 public으로 변경
- 각 서비스에서 알림 메시지를 직접 전달하도록 수정
@leesumin0526 leesumin0526 changed the title [FEAT/#487] Inquiry · Student usable · Device Token 커스텀 도메인 메트릭 추가 [FEAT/#487] 커스텀 도메인 메트릭 · 운영 Discord 알림 추가 Oct 6, 2026
@leesumin0526
leesumin0526 merged commit 3c4e773 into develop Oct 6, 2026
2 checks passed
@leesumin0526 leesumin0526 mentioned this pull request Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT/#487] 커스텀 도메인 메트릭 · 운영 Discord 알림 추가

2 participants