Skip to content

feat: API 실행과정을 트레이싱하기 위한 스프링 인터셉터 추가#34

Merged
mjkhub merged 3 commits intomainfrom
feature/api-interceptor
Jul 3, 2025
Merged

feat: API 실행과정을 트레이싱하기 위한 스프링 인터셉터 추가#34
mjkhub merged 3 commits intomainfrom
feature/api-interceptor

Conversation

@mjkhub
Copy link
Copy Markdown
Contributor

@mjkhub mjkhub commented Jul 2, 2025

API 요청에 UUID를 부여하고, 요청을 응답하는데 걸리는 시간을 로그로 남기는 간단한 스프링 인터셉터를 추가해보았습니다.

@sudo-Terry sudo-Terry self-requested a review July 2, 2025 04:19
Comment on lines +26 to +30
if (handler instanceof HandlerMethod handlerMethod) {
log.info("REQUEST [{}][{}][{}]", logId, requestURI, handlerMethod.getMethod().getName());
} else {
log.info("REQUEST [{}][{}][{}]", logId, requestURI, handler);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

경험적으로 클라이언트를 식별할 수 있는 clientIp와 같은 사용자 식별 정보가 로그에 찍히지 않으면 불편하더라구요.
실제 서비스가 올라가게 되면 로그 데이터가 방대하게 쌓이게 되어 필요한 로그를 찾기 어려웠습니다.

지금 수준의 기록으로는 응답 지연의 정도를 확인하거나 트래픽을 확인하는 정도로만 활용이 가능할 것 같아요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

넵 조금 더 구체화 해보겠습니다~

Copy link
Copy Markdown
Contributor Author

@mjkhub mjkhub Jul 2, 2025

Choose a reason for hiding this comment

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

사용자를 구분하고자 쿼리 파라미터로 전달되는 memberId 값을 읽어와서 로그에 추가하도록 수정했습니다~

Copy link
Copy Markdown
Member

@sudo-Terry sudo-Terry left a comment

Choose a reason for hiding this comment

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

LGTM!

@mjkhub mjkhub merged commit 3f83a26 into main Jul 3, 2025
1 check passed
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.

2 participants