Skip to content
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

chore: Sentry 필터링 적용 #777

Merged
merged 4 commits into from
Sep 18, 2024
Merged

Conversation

uwoobeat
Copy link
Member

@uwoobeat uwoobeat commented Sep 18, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 캡쳐할 이벤트 로그 레벨을 info -> warn으로 변경
  • 현재는 sentry를 일종의 로그 수집기로 사용하고 있었지만 본래 용도는 에러 모니터링이 맞습니다
  • 원래 용도에 맞게 warn으로 설정하고, 일반 로그의 경우 추후 cloudwatch 등으로 수집할 예정입니다
  • 크롤링 요청으로 인해 존재하지 않는 정적 리소스로 접근하여 발생하는 NoResourceFoundException / 유효하지 않은 바디 혹은 파라미터로 인한 예외를 센트리가 캡쳐하지 않도록 수정했습니다.
  • sentry 에이전트에서 프로메테우스 엔드포인트에 대한 트랜잭션 이벤트를 보내고 있어 액추에이터 엔드포인트 url 세그먼트가 포함된 경우 캡쳐에서 제외하도록 설정했습니다.

📝 참고사항

📚 기타

Summary by CodeRabbit

Summary by CodeRabbit

  • 새로운 기능

    • Sentry 관련 상수를 정의하는 SentryConstant 클래스 추가.
    • Sentry 오류 추적 시스템에서 무시할 예외 목록에 NoResourceFoundExceptionMethodArgumentNotValidException 추가.
    • 특정 트랜잭션을 Sentry로 전송하기 전에 필터링하는 CustomBeforeSendTransactionCallback 클래스 추가.
  • 구성 변경

    • Sentry의 이벤트 로깅 설정에서 최소 이벤트 수준을 warn으로 변경하여 경고 이상의 이벤트만 기록하도록 조정.

@uwoobeat uwoobeat requested a review from a team as a code owner September 18, 2024 08:38
@uwoobeat uwoobeat self-assigned this Sep 18, 2024
Copy link

coderabbitai bot commented Sep 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

이번 변경 사항은 Sentry와 관련된 상수 및 예외 처리 기능을 추가하고, Sentry의 트랜잭션 전송 방식을 사용자 정의하는 새로운 클래스를 도입합니다. 또한, Sentry의 로깅 설정을 수정하여 경고 수준 이상의 이벤트만 기록하도록 변경하였습니다. 이러한 변경은 Sentry의 오류 추적 및 로깅 기능을 개선하는 데 중점을 두고 있습니다.

Changes

파일 경로 변경 요약
src/main/java/com/gdschongik/gdsc/global/common/constant/SentryConstant.java Sentry 관련 상수를 정의하는 SentryConstant 클래스 추가, ACTUATOR_KEYWORDKEYWORDS_TO_IGNORE 상수 추가.
src/main/java/com/gdschongik/gdsc/global/config/SentryConfig.java Sentry에서 무시할 예외 목록에 NoResourceFoundExceptionMethodArgumentNotValidException 추가.
src/main/java/com/gdschongik/gdsc/infra/sentry/CustomBeforeSendTransactionCallback.java Sentry 트랜잭션 전송을 위한 사용자 정의 콜백 클래스 추가, 특정 키워드를 가진 트랜잭션을 필터링하는 로직 구현.
src/main/resources/application-sentry.yml Sentry의 로깅 설정에서 minimum-event-levelinfo에서 warn으로 변경.

Assessment against linked issues

Objective Addressed Explanation
Sentry가 특정 엔드포인트 접근 이벤트를 캡쳐하지 않도록 설정 ( #776 )
불필요한 접근(외부 크롤링 요청, 파비콘 등)을 캡쳐하지 않도록 수정 ( #776 ) 불필요한 접근을 필터링하는 로직이 있지만, 구체적인 예외 목록은 명시되지 않음.

Possibly related PRs

Suggested reviewers

  • seulgi99
  • Sangwook02
  • AlmondBreez3

Poem

🐰
변화의 바람이 불어와,
Sentry가 더 똑똑해졌네.
무시할 키워드로 깔끔하게,
오류 추적이 한결 수월해.
경고만 기록해, 소음은 줄여,
Rabbit의 기쁨, 함께 나누네! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for code reviews. This model has advanced reasoning capabilities and can provide more nuanced feedback on your code.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

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

Outside diff range and nitpick comments (1)
src/main/java/com/gdschongik/gdsc/global/common/constant/SentryConstant.java (1)

5-5: 클래스명 수정 제안

SentryConstant 클래스를 SentryConstants로 변경하는 것을 고려해보세요. 여러 상수를 포함하고 있으므로 복수형을 사용하면 더 명확합니다.

수정 사항 제안:

-public class SentryConstant {
+public class SentryConstants {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e60e0d9 and 84c5d95.

Files selected for processing (4)
  • src/main/java/com/gdschongik/gdsc/global/common/constant/SentryConstant.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/global/config/SentryConfig.java (1 hunks)
  • src/main/java/com/gdschongik/gdsc/infra/sentry/CustomBeforeSendTransactionCallback.java (1 hunks)
  • src/main/resources/application-sentry.yml (1 hunks)
Additional comments not posted (2)
src/main/resources/application-sentry.yml (1)

13-13: 로그 레벨 변경 확인 필요

minimum-event-levelinfo에서 warn으로 변경하셨습니다. 이로 인해 info 레벨의 이벤트는 Sentry에 전송되지 않습니다. 의도한 변경인지 확인 부탁드립니다.

src/main/java/com/gdschongik/gdsc/infra/sentry/CustomBeforeSendTransactionCallback.java (1)

22-23: 특정 트랜잭션 필터링 동작 확인

KEYWORDS_TO_IGNORE에 포함된 키워드를 가진 트랜잭션을 Sentry에서 필터링하도록 구현하셨습니다. 해당 키워드를 포함하는 트랜잭션이 모니터링되지 않게 됩니다. 의도한 동작인지 확인 부탁드립니다.

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.servlet.resource.NoResourceFoundException;
Copy link

Choose a reason for hiding this comment

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

올바른 예외 클래스 사용 필요

NoResourceFoundException 클래스는 존재하지 않을 수 있습니다. Spring MVC에서는 존재하지 않는 엔드포인트에 대한 예외로 NoHandlerFoundException을 사용합니다. 이 클래스로 수정하는 것을 권장합니다.

수정 사항 제안:

-import org.springframework.web.servlet.resource.NoResourceFoundException;
+import org.springframework.web.servlet.NoHandlerFoundException;

예외 목록에서의 변경:

-private final List<Class<? extends Throwable>> exceptionsToIgnore = List.of(
-        NoResourceFoundException.class, // 존재하지 않는 엔드포인트로 요청이 들어왔을 때
+private final List<Class<? extends Throwable>> exceptionsToIgnore = List.of(
+        NoHandlerFoundException.class, // 존재하지 않는 엔드포인트로 요청이 들어왔을 때
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
import org.springframework.web.servlet.resource.NoResourceFoundException;
import org.springframework.web.servlet.NoHandlerFoundException;

Copy link
Member

@Sangwook02 Sangwook02 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

@uwoobeat uwoobeat merged commit add30b8 into develop Sep 18, 2024
1 check passed
@uwoobeat uwoobeat deleted the chore/776-sentry-filtering branch September 18, 2024 08:58
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.

⚙️ Sentry 필터링 적용
2 participants