-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Sentry와 SpringBoot 로깅 프레임워크(log4j2) 연동 #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough인프라에 Sentry 연동이 추가되고 각 모듈에 app.module-name 설정이 도입되었습니다. Sentry 관련 프로퍼티·설정 클래스·로그 appender 및 빌드 의존성이 추가되었고, InfraBaseConfigGroup 및 apis 모듈 설정에 SENTRY가 등록되었습니다. Changes
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this 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
📒 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-jakarta와sentry-log4j2모두 8.22.0 버전이 정상적으로 배포되어 있음을 확인했습니다. 빌드 실패 걱정 없습니다.
infra/src/main/kotlin/org/yapp/infra/config/external/sentry/SentryConfig.kt
Outdated
Show resolved
Hide resolved
| send-default-pii: true | ||
| logs: | ||
| enabled: true | ||
| logging: | ||
| minimum-event-level: error | ||
| minimum-breadcrumb-level: info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: falseAlso 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.
| <!-- Sentry Appender --> | ||
| <Sentry name="Sentry" level="ERROR"/> | ||
| </Appenders> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| <!-- 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.
There was a problem hiding this 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
📒 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
| @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) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentry 옵션 커스터마이저 타입이 잘못되어 적용되지 않습니다
현재 @Bean이 Sentry.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)).
|



🔗 관련 이슈
📘 작업 유형
📙 작업 내역
🧪 테스트 내역
🎨 스크린샷 또는 시연 영상 (선택)
✅ PR 체크리스트
💬 추가 설명 or 리뷰 포인트 (선택)
Summary by CodeRabbit
신기능
작업