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

Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 #572

Merged
merged 7 commits into from
Oct 10, 2023

Conversation

jjongwa
Copy link
Member

@jjongwa jjongwa commented Sep 14, 2023

📄 Summary

일단 우리 5차 데모데이 요구사항

image

저희 API가 왠만한건 다 auth 걸려 있어서 그냥 테스트 엔티티랑 컨트롤러 만들어서 실험해 봤는데 잘 나오네요
image

이제 두 가지 방법이 있습니다.

  1. 이 PR을 merge하고 hanglog.site에서 QA 하면서 각 API 별 쿼리 정리
  2. 젠킨스 파이프라인 설정 변경해 해당 브랜치를 dev 대신 배포한 뒤 테스트

🙋🏻 More

thx to ur (우르 스펠링 모름)

@jjongwa jjongwa self-assigned this Sep 14, 2023
@jjongwa jjongwa linked an issue Sep 14, 2023 that may be closed by this pull request
3 tasks
@github-actions
Copy link

github-actions bot commented Sep 14, 2023

📝 Jacoco Test Coverage

Total Project Coverage 82.98% 🍏
File Coverage [99.59%]
ConnectionProxyHandler.java 100% 🍏
PreparedStatementProxyHandler.java 100% 🍏
LoggingForm.java 100% 🍏
QueryCounterAop.java 98.65% 🍏

Copy link
Collaborator

@hgo641 hgo641 left a comment

Choose a reason for hiding this comment

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

잘 보고 갑니다 + 1. dev에 머지해서 보자

Comment on lines 25 to 30
if (JDBC_QUERY_METHOD.contains(method.getName())) {
final long startTime = System.currentTimeMillis();
final Object result = invocation.proceed();
final long endTime = System.currentTimeMillis();

loggingForm.addQueryTime(endTime - startTime);
Copy link
Collaborator

Choose a reason for hiding this comment

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

이런 거 모니터링은 보통 ms단위로 보나요?
0.002s 처럼 보는 경우는 별로 없으려나? 보통 ms정도만 소요될테니까?

@LJW25
Copy link
Collaborator

LJW25 commented Sep 15, 2023

저는 3. 이 브랜치를 dev 서버에 배포해서 확인하자 한표하겠습니다.
1&2 둘다 번거롭게 느껴져서 쿼리 파악 할때 잠시만 이 브랜치로 배포하고 파악 후에 develop 브랜치로 돌리거나 말거나..? 하면 좋을지도?

@jjongwa jjongwa changed the title N+1 Detector 구현 Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 Sep 21, 2023
Comment on lines 17 to 20
protected void afterRequest(@NonNull final HttpServletRequest request, @NonNull final String message) {
logger.info(message);
// logger.info(message);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 데브에 머지할거면 제가 한거지만 지워주시면 감사하겠습니다 ? (그 때 테스트하려고 잠깐 주석으로 넣어놓은거라 ㅎㅎ)
그리고 프로메테우스 로깅 제외하는 것도 넣으면 좋을거 같아요 ...

if (!message.contains("prometheus")) {
    logger.info(message);
}

쿼카 PR에서 반영안해도 되고, 로깅 PR에서 반영되도 좋을거 같지만? 이것도 기록 남기기용으로 남깁니다 ~

@mcodnjs mcodnjs merged commit 634d632 into develop Oct 10, 2023
dladncks1217 added a commit that referenced this pull request Oct 12, 2023
* Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 (#572)

* feat: N+1 detector 적용

* feat: AOP 스프링 빈 등록

* chore: rebase develop

* chore: p6spy 재적용

* refactor: info-appender logging 패턴 수정

* refactor: info-appender logging 패턴 개행 추가

* refactor: 패키지 위치 및 네이밍 변경

---------

Co-authored-by: mcodnjs <[email protected]>

* feat: ts-loader -> esbuild-loader 마이그레이션

* refactor: fork-ts-checker-webpack-plugin 동작 문제 수정

---------

Co-authored-by: 신종화 <[email protected]>
Co-authored-by: mcodnjs <[email protected]>
dladncks1217 added a commit that referenced this pull request Oct 12, 2023
* refactor:아이템추가 모달 백드랍 클릭해도 닫히지 않게 함

* refactor: 커뮤니티여행 아이템 상세정보 줄바꿈 적용

* refactor:모바일  모달에서 '확인버튼' 항상 화면에 보이도록 설정

* feat:커뮤니티 여행, 작성자 본인일 경우 수정페이지 이동버튼

* refactor: 뱃지높이, 타이틀 너비 조정

* refactor: 쿼리별 캐싱시간 설정

* fix: 여행정보 수정시 바로 반영되도록 tripData주입받음

* refactor: expense페이지, isshared대신 tripType으로 상태변경

* feat:여행정보수정 이미지 업로드시 버튼 클릭 불가능

* chore:불필요한 라인 제거, 절대경로수정

* chore: mock data 원상복귀(테스트 실패로인한)

* Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 (#572)

* feat: N+1 detector 적용

* feat: AOP 스프링 빈 등록

* chore: rebase develop

* chore: p6spy 재적용

* refactor: info-appender logging 패턴 수정

* refactor: info-appender logging 패턴 개행 추가

* refactor: 패키지 위치 및 네이밍 변경

---------

Co-authored-by: mcodnjs <[email protected]>

* feat: ts-loader -> esbuild-loader 마이그레이션

* refactor: fork-ts-checker-webpack-plugin 동작 문제 수정

* Member 탈퇴에 따른 엔티티 Soft Delete 처리 성능 개선 (#687)

* feat: memberId로 tripId 리스트 반환하는 기능 추가

* feat: tripId 리스트로 dayLogId 리스트 반환하는 기능 추가

* feat: dayLogId 리스트로 itemId 리스트 반환하는 기능 추가

* refactor: itemId, placeId, expenseId를 가진 DTO 리스트 반환하도록 변경

* refactor: memberId에 따른 엔티티 status 변경 및 refreshToken 삭제 성능 개선

* refactor: repository 구현체 패키지 변경

* refactor: SharedTrip, PublishedTrip도 함께 업데이트되도록 변경

* refactor: event 적용

* refactor: 트랜잭션 분리

* refactor: `@Async`로 비동기 처리

* refactor: 메서드 분리

* test: AuthServiceIntegrationTest 수정

* test: MemberDeleteEventListener Mock Test 작성

* refactor: indent 변경

* refactor: final 추가

* refactor: event 관련 클래스 패키지 위치 변경

* refactor: SharedStatusType 위치 변경

* refactor: WriterResponse 위치 변경

* refactor: PublishedStatusType 위치 변경

* refactor: 백엔드 이미지로직 변경에 의한 코드 수정

* chore: 코드 컨벤션에 의한 코드 수정

* refactor: 테스트코드 문제 해결을 위한 코드 수정

* refactor: 테스트코드 문제로 인한 코드 리팩토링

* refactor: 불필요한 파일 제거

---------

Co-authored-by: dahyeee <[email protected]>
Co-authored-by: 신종화 <[email protected]>
Co-authored-by: mcodnjs <[email protected]>
Co-authored-by: Dahye Yun <[email protected]>
jjongwa added a commit that referenced this pull request Oct 12, 2023
* refactor:아이템추가 모달 백드랍 클릭해도 닫히지 않게 함

* refactor: 커뮤니티여행 아이템 상세정보 줄바꿈 적용

* refactor:모바일  모달에서 '확인버튼' 항상 화면에 보이도록 설정

* feat:커뮤니티 여행, 작성자 본인일 경우 수정페이지 이동버튼

* refactor: 뱃지높이, 타이틀 너비 조정

* refactor: 쿼리별 캐싱시간 설정

* fix: 여행정보 수정시 바로 반영되도록 tripData주입받음

* refactor: expense페이지, isshared대신 tripType으로 상태변경

* feat:여행정보수정 이미지 업로드시 버튼 클릭 불가능

* chore:불필요한 라인 제거, 절대경로수정

* chore: mock data 원상복귀(테스트 실패로인한)

* Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 (#572)

* feat: N+1 detector 적용

* feat: AOP 스프링 빈 등록

* chore: rebase develop

* chore: p6spy 재적용

* refactor: info-appender logging 패턴 수정

* refactor: info-appender logging 패턴 개행 추가

* refactor: 패키지 위치 및 네이밍 변경

---------

Co-authored-by: mcodnjs <[email protected]>

* feat: ts-loader -> esbuild-loader 마이그레이션

* refactor: fork-ts-checker-webpack-plugin 동작 문제 수정

* Member 탈퇴에 따른 엔티티 Soft Delete 처리 성능 개선 (#687)

* feat: memberId로 tripId 리스트 반환하는 기능 추가

* feat: tripId 리스트로 dayLogId 리스트 반환하는 기능 추가

* feat: dayLogId 리스트로 itemId 리스트 반환하는 기능 추가

* refactor: itemId, placeId, expenseId를 가진 DTO 리스트 반환하도록 변경

* refactor: memberId에 따른 엔티티 status 변경 및 refreshToken 삭제 성능 개선

* refactor: repository 구현체 패키지 변경

* refactor: SharedTrip, PublishedTrip도 함께 업데이트되도록 변경

* refactor: event 적용

* refactor: 트랜잭션 분리

* refactor: `@Async`로 비동기 처리

* refactor: 메서드 분리

* test: AuthServiceIntegrationTest 수정

* test: MemberDeleteEventListener Mock Test 작성

* refactor: indent 변경

* refactor: final 추가

* refactor: event 관련 클래스 패키지 위치 변경

* refactor: SharedStatusType 위치 변경

* refactor: WriterResponse 위치 변경

* refactor: PublishedStatusType 위치 변경

* chore: conflict resolve

* refactor: ItemRequest 필드 변화에 따른 변경사항 반영

* refactor: ItemUpdateRequest 필드 변화에 따른 변경사항 반영

* refactor: ImageNameParser 제거

* refactor: 메서드 파라미터 변경

* refactor: 테스트에서 사용하는 매개변수 url-> name 형식으로 변경

* refactor: ItemResponse 필드 변경

* refactor: Trip 대표이미지 url -> name으로 변경

---------

Co-authored-by: dahyeee <[email protected]>
Co-authored-by: mcodnjs <[email protected]>
Co-authored-by: dladncks1217 <[email protected]>
Co-authored-by: Dahye Yun <[email protected]>
jjongwa added a commit that referenced this pull request Oct 19, 2023
* Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 (#572)

* feat: N+1 detector 적용

* feat: AOP 스프링 빈 등록

* chore: rebase develop

* chore: p6spy 재적용

* refactor: info-appender logging 패턴 수정

* refactor: info-appender logging 패턴 개행 추가

* refactor: 패키지 위치 및 네이밍 변경

---------

Co-authored-by: mcodnjs <[email protected]>

* feat: ts-loader -> esbuild-loader 마이그레이션

* refactor: fork-ts-checker-webpack-plugin 동작 문제 수정

---------

Co-authored-by: 신종화 <[email protected]>
Co-authored-by: mcodnjs <[email protected]>
jjongwa added a commit that referenced this pull request Oct 19, 2023
* refactor:아이템추가 모달 백드랍 클릭해도 닫히지 않게 함

* refactor: 커뮤니티여행 아이템 상세정보 줄바꿈 적용

* refactor:모바일  모달에서 '확인버튼' 항상 화면에 보이도록 설정

* feat:커뮤니티 여행, 작성자 본인일 경우 수정페이지 이동버튼

* refactor: 뱃지높이, 타이틀 너비 조정

* refactor: 쿼리별 캐싱시간 설정

* fix: 여행정보 수정시 바로 반영되도록 tripData주입받음

* refactor: expense페이지, isshared대신 tripType으로 상태변경

* feat:여행정보수정 이미지 업로드시 버튼 클릭 불가능

* chore:불필요한 라인 제거, 절대경로수정

* chore: mock data 원상복귀(테스트 실패로인한)

* Query Counter (aka. N+1 Detector) 를 통한 API별 쿼리 정보 정리 (#572)

* feat: N+1 detector 적용

* feat: AOP 스프링 빈 등록

* chore: rebase develop

* chore: p6spy 재적용

* refactor: info-appender logging 패턴 수정

* refactor: info-appender logging 패턴 개행 추가

* refactor: 패키지 위치 및 네이밍 변경

---------

Co-authored-by: mcodnjs <[email protected]>

* feat: ts-loader -> esbuild-loader 마이그레이션

* refactor: fork-ts-checker-webpack-plugin 동작 문제 수정

* Member 탈퇴에 따른 엔티티 Soft Delete 처리 성능 개선 (#687)

* feat: memberId로 tripId 리스트 반환하는 기능 추가

* feat: tripId 리스트로 dayLogId 리스트 반환하는 기능 추가

* feat: dayLogId 리스트로 itemId 리스트 반환하는 기능 추가

* refactor: itemId, placeId, expenseId를 가진 DTO 리스트 반환하도록 변경

* refactor: memberId에 따른 엔티티 status 변경 및 refreshToken 삭제 성능 개선

* refactor: repository 구현체 패키지 변경

* refactor: SharedTrip, PublishedTrip도 함께 업데이트되도록 변경

* refactor: event 적용

* refactor: 트랜잭션 분리

* refactor: `@Async`로 비동기 처리

* refactor: 메서드 분리

* test: AuthServiceIntegrationTest 수정

* test: MemberDeleteEventListener Mock Test 작성

* refactor: indent 변경

* refactor: final 추가

* refactor: event 관련 클래스 패키지 위치 변경

* refactor: SharedStatusType 위치 변경

* refactor: WriterResponse 위치 변경

* refactor: PublishedStatusType 위치 변경

* refactor: 백엔드 이미지로직 변경에 의한 코드 수정

* chore: 코드 컨벤션에 의한 코드 수정

* refactor: 테스트코드 문제 해결을 위한 코드 수정

* refactor: 테스트코드 문제로 인한 코드 리팩토링

* refactor: 불필요한 파일 제거

---------

Co-authored-by: dahyeee <[email protected]>
Co-authored-by: 신종화 <[email protected]>
Co-authored-by: mcodnjs <[email protected]>
Co-authored-by: Dahye Yun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

N+1 문제 파악을 위한 detector 구현
5 participants