Skip to content

PB-120 MDC3: 스케줄러 MDC + 도메인 구조화 로그 - #232

Merged
PHJ2000 merged 2 commits into
mainfrom
feat/PB-120-mdc3-logging-context
Jun 19, 2026
Merged

PHJ2000 merged 2 commits into
mainfrom
feat/PB-120-mdc3-logging-context

Conversation

@geonusp

@geonusp geonusp commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

✨ Feature PR

🔗 이슈 링크


🧩 이 PR의 변경사항

이 PR에서 변경한 것

  • 스케줄러 실행 구간에 schedulerName, jobId 짧은 MDC scope 적용 (OutboxSchedulingConfig, BeachConditionScheduler)
  • 도메인 식별자(notificationId, outboxEventId 등)를 StructuredArguments.kv로 기록 (NotificationService, OutboxPublisher, OutboxEventDispatcher)
  • logback-spring.xml dev/prod 로그에 schedulerName, jobId 노출
  • 로그 포맷/스케줄러 MDC 누수 방지 테스트 보강 (DtoLoggingCatalogTest, BeachConditionSchedulerTest, 신규 OutboxSchedulingConfigTest)

선행: MDC1(HTTP requestId/userId), MDC2(@async 전파, PB-119 #229)
근거: ADR-010 로깅 표준 §3 MDC 표준 키, §4 도메인 로그 필드 정책, §5 스케줄러 MDC 정책


✅ AC (이 PR 범위만)

  • logback-spring.xml dev/prod 로그에 schedulerName, jobId 노출
  • Outbox/BeachCondition 스케줄러 실행 중 schedulerName/jobId MDC 주입, 종료 후 누수 없음 (테스트 검증)
  • NotificationService/OutboxEventDispatcher 로그에 도메인 식별자가 structured field로 기록
  • 스케줄러에 requestId/userId 미주입, traceId/spanId 직접 생성 안 함
  • MdcScope helper 미포함 (반복 패턴 2곳 이상 확인 시 후속 PR)

🧪 테스트 결과

로컬

./gradlew test --tests "com.beachcheck.global.logging.DtoLoggingCatalogTest" \
  --tests "com.beachcheck.beach.scheduler.BeachConditionSchedulerTest" \
  --tests "com.beachcheck.outbox.config.OutboxSchedulingConfigTest" \
  --tests "com.beachcheck.outbox.service.OutboxPublisherTest" \
  --tests "com.beachcheck.outbox.service.OutboxEventDispatcherTest"
  • ✅ 결과: BUILD SUCCESSFUL (단위 테스트 통과). spotlessApply 적용 완료.
  • ℹ️ Testcontainers 통합 테스트(outbox.integration.*)는 Docker 필요로 본 변경 범위에서 미실행.

🧭 영향 범위 체크

  • API 변경
  • DB 변경
  • 설정 변경
  • Breaking change
  • (로그 필드 추가만 — API/DB/외부 연동 런타임 계약 변경 없음)

💬 리뷰 포인트

  • 집중해서 볼 파일/라인:
    • OutboxEventDispatcher: 성공/멱등스킵/영구실패/재시도 경로별 structured 로그 (중복 로깅 없는지)
    • 스케줄러 try (MDC.MDCCloseable ...) scope 종료 시 MDC 정리
  • 트레이드오프/대안: 도메인 식별자를 MDC가 아닌 structured argument로 둔 이유는 스레드 재사용 누수/필드 의미 혼동 방지 (ADR-010 §4 근거).

- logback-spring.xml에 schedulerName, jobId MDC 키 노출 (dev/prod)
- OutboxSchedulingConfig, BeachConditionScheduler 스케줄러 실행 구간 MDC scope 적용
- NotificationService, OutboxPublisher, OutboxEventDispatcher 도메인 식별자 structured 로그 추가
- 로그 포맷/스케줄러 MDC 누수 방지 테스트 보강
@geonusp geonusp added the feat label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d1f74761-4306-4ae6-95c9-64b0cb9bbad4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/PB-120-mdc3-logging-context

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 and usage tips.

@geonusp geonusp self-assigned this Jun 15, 2026
@geonusp
geonusp requested a review from PHJ2000 June 15, 2026 18:00
@PHJ2000
PHJ2000 merged commit 0b87efd into main Jun 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] PB-120 MDC3: 스케줄러 MDC + 도메인 구조화 로그

2 participants