Skip to content

feat: 요청 추적용 MDC traceId/userId 로깅 main에 포팅 - #239

Merged
unam98 merged 2 commits into
mainfrom
feat/mdc-trace-logging-to-main
Aug 11, 2026
Merged

feat: 요청 추적용 MDC traceId/userId 로깅 main에 포팅#239
unam98 merged 2 commits into
mainfrom
feat/mdc-trace-logging-to-main

Conversation

@unam98

Copy link
Copy Markdown
Collaborator

작업 배경

dev에서 검증됐던 요청 추적 로깅(MdcLoggingFilter + logback-spring.xml)이 트렁크 기반 전환 콘텐츠 정합화 때 "로컬 모니터링 스택 전용"으로 오판되어 main에 없었다. 실제로는 ELK 연동 없이도 독립적으로 동작하는(콘솔+파일 appender만 사용) 순수 로깅 기능이라 포팅한다.

변경 사항

영역내용
config/logging/MdcLoggingFilter.java (신규)요청마다 8자리 traceId 발급 + JWT 헤더로 best-effort userId 채움, finally에서 반드시 MDC.remove (톰캣 스레드 재사용 시 이전 요청 값 누수 방지)
resources/logback-spring.xml (신규)로그 패턴에 %X{traceId} 포함, Console + RollingFile(30일 보관, gzip 압축) appender
common/resolver/userId/UserIdResolver.java실제 인증 검증을 거친 요청은 이 클래스가 더 정확한 userId로 MDC 값을 덮어쓰도록 MDC.put 추가
common/resolver/userId/UserIdResolverTest.javaMDC에 값이 채워지는지 검증하는 assertion 추가, 테스트 격리를 위한 @AfterEach MDC.clear()

영향 범위

  • 로그 출력 포맷/보관 방식만 바뀜 — API 응답/비즈니스 로직 변화 없음
  • ./logs 디렉터리에 롤링 로그 파일이 쌓이기 시작함 (30일 보관 후 자동 삭제)

Test Plan

  • 로컬 postgres/redis 기동 후 ./gradlew test 전체 254/254 통과
  • 로컬 실행 로그에서 [traceId] [userId=] 패턴이 실제로 찍히는 것 확인

🤖 Generated with Claude Code

dev에서 검증된 MdcLoggingFilter(요청마다 8자리 traceId 발급)와
logback-spring.xml(콘솔+롤링파일 appender, 로그 패턴에 traceId 포함)을
main에 반영한다. ELK 연동 없이 순수 Logback 설정이라 prod에 넣어도
안전하다.
MdcLoggingFilter는 JWT 헤더에서 best-effort로 userId도 채우는데,
@userid 파라미터로 실제 인증 검증을 거친 요청은 UserIdResolver가
더 정확한 값으로 덮어써야 해서 그쪽에도 MDC.put을 같이 추가했다
(dev에서 이미 이렇게 짝을 이루던 설계).
@coderabbitai

coderabbitaiBot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@unam98, you've reached your PR review limit, so we couldn't start this review.

Next review available in:6 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ba9d4a4b-129d-4aa5-b4c4-0457e1aac99a

📥 Commits

Reviewing files that changed from the base of the PR and between a54fb2a and ba94500.

📒 Files selected for processing (6)
  • .github/workflows/prod-cd.yml
  • .github/workflows/prod-ci.yml
  • src/main/java/org/runnect/server/common/resolver/userId/UserIdResolver.java
  • src/main/java/org/runnect/server/config/logging/MdcLoggingFilter.java
  • src/main/resources/logback-spring.xml
  • src/test/java/org/runnect/server/common/resolver/userId/UserIdResolverTest.java

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.

logback-spring.xml이 main에 추가되면서 src/main/resources 디렉터리가
이미 git에 존재하게 됐다. 기존 mkdir(비-p)은 디렉터리가 이미 있으면
실패해서 CI/CD가 깨졌다 (mkdir: cannot create directory: File exists).
@unam98
unam98 merged commit 74c0679 into mainAug 11, 2026
2 checks passed
@unam98
unam98 deleted the feat/mdc-trace-logging-to-main branch August 11, 2026 08:02
Sign up for freeto 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.

2 participants

@unam98@alh0409