Skip to content

Conversation

@move-hoon
Copy link
Member

@move-hoon move-hoon commented Sep 27, 2025

🔗 관련 이슈

📘 작업 유형

  • ✨ Feature (기능 추가)
  • 🐞 Bugfix (버그 수정)
  • 🔧 Refactor (코드 리팩토링)
  • ⚙️ Chore (환경 설정)
  • 📝 Docs (문서 작성 및 수정)
  • ✅ Test (기능 테스트)
  • 🎨 style (코드 스타일 수정)

📙 작업 내역

  • Sentry와 SpringBoot 로깅 프레임워크(log4j2)를 연동했습니다. (현재 저희는 log4j2 로깅 프레임워크를 사용하기 때문에, Spring Boot 애플리케이션에 Sentry의 Log4j2 통합하는 작업을 진행했습니다.
  • 아래는 세팅 관련 공식 문서라서 참고해보셔도 좋을 것 같습니다!!

🧪 테스트 내역

  • 브라우저/기기에서 동작 확인
  • 엣지 케이스 테스트 완료
  • 기존 기능 영향 없음

🎨 스크린샷 또는 시연 영상 (선택)

image
  • breadcrumb가 info 부터 잡히는 것을 확인했습니다. (이 부분 debug로 해보고 debug level 로깅도 해보았는데 info 레벨로 잡히긴합니다. 그런데 info 레벨로 AOP 로깅을 하기때문에 이 부분은 상관 없을 것 같습니다 ㅎㅎ)
image
  • 어느 모듈에서 발생했고, 어떤 환경(dev/prod)에서 발생했는지 모두 잘 작동하는 것을 확인했습니다.

✅ PR 체크리스트

  • 커밋 메시지가 명확합니다
  • PR 제목이 컨벤션에 맞습니다
  • 관련 이슈 번호를 작성했습니다
  • 기능이 정상적으로 작동합니다
  • 불필요한 코드를 제거했습니다

💬 추가 설명 or 리뷰 포인트 (선택)

  • ..

Summary by CodeRabbit

  • 신기능

    • Sentry 기반 오류 모니터링과 로그 전송을 도입했습니다.
    • 모듈 이름 설정(app.module-name)을 각 서비스(admin, apis, batch)에 추가해 서비스별 태깅이 가능해졌습니다.
  • 작업

    • Sentry 초기화 및 설정을 위한 구성과 프로퍼티를 추가했습니다.
    • 빌드 의존성에 Sentry 라이브러리를 포함하고 로깅 설정을 Sentry Appender로 전환했습니다.
    • 공통 및 테스트 프로필에 Sentry 기본 설정(DSN, 환경, 로그 수준 등)을 구성했습니다.

@move-hoon move-hoon self-assigned this Sep 27, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 27, 2025

Walkthrough

인프라에 Sentry 연동이 추가되고 각 모듈에 app.module-name 설정이 도입되었습니다. Sentry 관련 프로퍼티·설정 클래스·로그 appender 및 빌드 의존성이 추가되었고, InfraBaseConfigGroup 및 apis 모듈 설정에 SENTRY가 등록되었습니다.

Changes

Cohort / File(s) Summary
모듈 식별자 설정 추가
admin/src/main/resources/application.yml, apis/src/main/resources/application.yml, batch/src/main/resources/application.yml
최상위 프로퍼티 app.module-name 추가(admin, apis, batch).
Infra 그룹 및 활성화 변경
apis/src/main/kotlin/org/yapp/apis/config/InfraConfig.kt, infra/src/main/kotlin/org/yapp/infra/InfraBaseConfigGroup.kt
EnableInfraBaseConfigInfraBaseConfigGroup.SENTRY 추가 및 InfraBaseConfigGroupSENTRY(SentryConfig::class.java) enum 항목 추가.
Sentry 설정 코드 / 프로퍼티 클래스 추가
infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryConfig.kt, infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryProperties.kt
SentryProperties(@ConfigurationProperties(prefix="sentry")) 및 SentryConfig(@configuration, @EnableConfigurationProperties) 추가. DSN이 비어있으면 초기화 생략, 그렇지 않으면 DSN·environment·serverName 설정 및 "module" 태그 추가하는 Sentry Options customizer 빈 등록.
공통 설정·로깅 구성 변경
infra/src/main/resources/application-crosscutting.yml, infra/src/main/resources/log4j2-spring.xml
공통 YAML에 sentry 블록(기본 및 test) 추가. log4j2 구성에서 File appender 제거 후 Sentry appender 추가·루트·패키지 로거가 Sentry appender를 참조하도록 변경; 콘솔 패턴 통합.
빌드 의존성 추가
buildSrc/src/main/kotlin/Dependencies.kt, infra/build.gradle.kts
Dependencies.Sentry 객체와 두 상수(SPRING_BOOT_STARTER, LOG4J2) 추가. infra 모듈에 Sentry 관련 의존성 등록.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Starter as 애플리케이션 시작
  participant Spring as Spring Boot
  participant Props as SentryProperties
  participant Config as SentryConfig
  participant Sdk as Sentry SDK
  participant Log as Log4j2 (Sentry Appender)

  Starter->>Spring: 부트스트랩
  Spring->>Config: 빈 생성, 의존성 주입
  Config->>Props: sentry.* 프로퍼티 바인딩
  Config->>Config: @Value("\${app.module-name}")로 moduleName 주입

  alt sentry.dsn 비어있음
    Config-->>Spring: Sentry 초기화 생략
    note right of Config: App은 Sentry 미활성화 상태
  else sentry.dsn 존재
    Config->>Sdk: Options 설정(dsn, environment, serverName, tags[module])
    note right of Sdk: Sentry SDK 초기화
  end

  Log->>Sdk: ERROR 이상 로그 전송 (Sentry Appender)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 제목이 Sentry를 Spring Boot의 log4j2 로깅 프레임워크와 연동한다는 주요 변경 사항을 명확히 요약하고 있어 PR 내용과 잘 부합합니다.
Linked Issues Check ✅ Passed 의존성 추가부터 설정 클래스, 프로퍼티 바인딩, YAML 및 log4j2 구성까지 Sentry 연동을 위한 모든 요소가 구현되어 있어 링크된 이슈 #113의 에러 트래킹 목적을 충족합니다.
Out of Scope Changes Check ✅ Passed 추가된 모든 변경 사항이 Sentry 통합을 위해 필요한 의존성, 설정, 로깅 구성 및 모듈 식별자 주입과 직접 관련되어 있어 범위를 벗어난 수정은 없습니다.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BOOK-295-chore/#113

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b603502 and bc434c7.

📒 Files selected for processing (11)
  • admin/src/main/resources/application.yml (1 hunks)
  • apis/src/main/kotlin/org/yapp/apis/config/InfraConfig.kt (1 hunks)
  • apis/src/main/resources/application.yml (1 hunks)
  • batch/src/main/resources/application.yml (1 hunks)
  • buildSrc/src/main/kotlin/Dependencies.kt (1 hunks)
  • infra/build.gradle.kts (1 hunks)
  • infra/src/main/kotlin/org/yapp/infra/InfraBaseConfigGroup.kt (2 hunks)
  • infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryConfig.kt (1 hunks)
  • infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryProperties.kt (1 hunks)
  • infra/src/main/resources/application-crosscutting.yml (2 hunks)
  • infra/src/main/resources/log4j2-spring.xml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-validation
🔇 Additional comments (1)
buildSrc/src/main/kotlin/Dependencies.kt (1)

74-77: 해결됨: Sentry 8.22.0 버전이 Maven Central에 등록되어 있습니다

sentry-spring-boot-starter-jakartasentry-log4j2 모두 8.22.0 버전이 정상적으로 배포되어 있음을 확인했습니다. 빌드 실패 걱정 없습니다.

Comment on lines +18 to +23
send-default-pii: true
logs:
enabled: true
logging:
minimum-event-level: error
minimum-breadcrumb-level: info
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

send-default-pii true 설정은 개인정보 보호 정책을 위반할 수 있습니다

send-default-pii: true는 기본적으로 사용자 식별자·IP 등 PII를 Sentry로 전송합니다. 사전 동의나 법무 검토 없이 활성화하면 컴플라이언스 리스크가 커지므로 기본값을 false로 두거나 환경별로 명시적으로 허용했을 때만 켜지도록 조정해 주세요.

-  send-default-pii: true
+  send-default-pii: false
...
-  send-default-pii: true
+  send-default-pii: false

Also applies to: 46-51

🤖 Prompt for AI Agents
In infra/src/main/resources/application-crosscutting.yml around lines 18-23 (and
also apply the same change at lines 46-51), send-default-pii is set to true
which causes PII to be sent to Sentry; change the default to false and implement
an explicit opt-in mechanism (e.g., environment-specific profile or an
environment variable like SENTRY_SEND_PII=true) so PII is only enabled when
explicitly allowed and approved by legal; update the YAML to set
send-default-pii: false by default, add a comment indicating it must be
explicitly enabled per environment with legal approval, and ensure the
duplicated setting at lines 46-51 is updated consistently.

Comment on lines 36 to 38
<!-- Sentry Appender -->
<Sentry name="Sentry" level="ERROR"/>
</Appenders>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Sentry Appender의 level 속성이 무시되어 경고 로그가 발생합니다

Log4j2의 Sentry 플러그인은 level 속성을 지원하지 않아 부팅 시 “unrecognized attribute level” 경고가 남고 설정도 적용되지 않습니다. 공식 문서처럼 ThresholdFilter로 이벤트 레벨을 제어하도록 바꿔 주세요.

-        <Sentry name="Sentry" level="ERROR"/>
+        <Sentry name="Sentry">
+            <Filter type="ThresholdFilter" level="error"/>
+        </Sentry>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- Sentry Appender -->
<Sentry name="Sentry" level="ERROR"/>
</Appenders>
<!-- Sentry Appender -->
<Sentry name="Sentry">
<Filter type="ThresholdFilter" level="error"/>
</Sentry>
</Appenders>
🤖 Prompt for AI Agents
infra/src/main/resources/log4j2-spring.xml around lines 36-38: the Sentry
appender currently uses a non-supported level attribute which triggers
“unrecognized attribute level” at boot and has no effect; remove the
level="ERROR" attribute from the Sentry element and instead add a
ThresholdFilter child to the Sentry appender with level="ERROR",
onMatch="ACCEPT" and onMismatch="DENY" so only ERROR-and-above events are sent
to Sentry.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5c1597 and f6eafc1.

📒 Files selected for processing (3)
  • infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryConfig.kt (1 hunks)
  • infra/src/main/resources/application-crosscutting.yml (2 hunks)
  • infra/src/main/resources/log4j2-spring.xml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-validation
🔇 Additional comments (2)
infra/src/main/resources/application-crosscutting.yml (2)

13-16: 환경 변수 미설정 시 애플리케이션이 부팅에 실패합니다
SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_SERVER_NAME가 비어 있으면 IllegalArgumentException이 발생하여 애플리케이션이 시작되지 않습니다. 로컬/CI 등에서도 안전하게 동작하도록 기본값(빈 문자열 등)을 지정해 주세요.

-  dsn: ${SENTRY_DSN}
-  environment: ${SENTRY_ENVIRONMENT}
-  server-name: ${SENTRY_SERVER_NAME}
+  dsn: ${SENTRY_DSN:}
+  environment: ${SENTRY_ENVIRONMENT:}
+  server-name: ${SENTRY_SERVER_NAME:}

18-23: send-default-pii 기본값이 개인정보 보호 정책을 위반할 수 있습니다
send-default-pii: true는 사용자 식별자·IP 등 PII를 기본적으로 전송하므로 법무/보안 승인 없이 활성화하면 큰 리스크가 됩니다. 기본값을 false로 두고, 필요한 환경에서만 명시적으로 켜도록 바꿔 주세요.

-  send-default-pii: true
+  send-default-pii: ${SENTRY_SEND_DEFAULT_PII:false}
@@
-  send-default-pii: true
+  send-default-pii: ${SENTRY_SEND_DEFAULT_PII:false}

Also applies to: 46-51

Comment on lines +19 to +32
@Bean
fun sentryOptionsCustomizer(): Sentry.OptionsConfiguration<SentryOptions> {
return Sentry.OptionsConfiguration { options: SentryOptions ->
if (sentryProperties.dsn.isBlank()) {
options.isEnabled = false
return@OptionsConfiguration
}

options.dsn = sentryProperties.dsn
options.environment = sentryProperties.environment
options.serverName = sentryProperties.serverName
options.setTag("module", moduleName)
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Sentry 옵션 커스터마이저 타입이 잘못되어 적용되지 않습니다
현재 @BeanSentry.OptionsConfiguration을 반환하고 있어 Spring Boot Starter가 제공하는 커스터마이저 체인에 연결되지 않습니다. 그 결과 module 태그 주입과 DSN 미설정 시 비활성화 로직이 전혀 실행되지 않습니다. io.sentry.spring.boot.jakarta.SentryOptionsConfiguration을 반환하도록 수정해야 합니다.

-import io.sentry.Sentry
-import io.sentry.SentryOptions
+import io.sentry.SentryOptions
+import io.sentry.spring.boot.jakarta.SentryOptionsConfiguration
@@
-    fun sentryOptionsCustomizer(): Sentry.OptionsConfiguration<SentryOptions> {
-        return Sentry.OptionsConfiguration { options: SentryOptions ->
+    fun sentryOptionsCustomizer(): SentryOptionsConfiguration<SentryOptions> {
+        return SentryOptionsConfiguration { options: SentryOptions ->
🤖 Prompt for AI Agents
In infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryConfig.kt
around lines 19 to 32, the @Bean currently returns Sentry.OptionsConfiguration
which prevents Spring Boot Starter's customizer chain from being used; change
the bean to return
io.sentry.spring.boot.jakarta.SentryOptionsConfiguration<SentryOptions> (the
Spring Boot-provided interface) and adapt the lambda signature to match that
type so Spring will wire it into the starter’s customizer chain; update imports
to use io.sentry.spring.boot.jakarta.SentryOptionsConfiguration and keep the
existing logic (disable when DSN is blank, set dsn/environment/serverName, and
setTag("module", moduleName)).

@sonarqubecloud
Copy link

@move-hoon move-hoon merged commit cbff2cf into develop Sep 27, 2025
3 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.

[BOOK-295/chore] Sentry 연동

2 participants