-
Notifications
You must be signed in to change notification settings - Fork 1
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
[BSVR-55] P6spy를 이용한 쿼리 로그 설정 #12
Conversation
@@ -23,3 +23,5 @@ version.org.springframework.boot..spring-boot-starter-data-jpa=3.0.1 | |||
|
|||
version.org.springdoc..springdoc-openapi-starter-webmvc-ui=2.5.0 | |||
|
|||
version.com.github.gavlyukovskiy..p6spy-spring-boot-starter=1.9.0 |
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.
1.9.0버전부터 spring boot3 지원! 업그레이드는 되는데, 다운그레이드는 하지 않도록 주의 필요~~
decorator: | ||
datasource: | ||
p6spy: | ||
enable-logging: true |
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.
enable-logging을 true로 두면 p6spy가 동작해.
자원을 많이 잡아먹는 라이브러리라서, 운영환경에 배포할 땐 false로 바꾸고 배포해야해.
prod profile를 새로 만들때 주의하면 될 듯~
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.
확인!
return String.format( | ||
"[%s] | took %d ms | connectionId %d | %s | %s", | ||
category, elapsed, connectionId, filterStack(), formatSql(category, sql)); |
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.
차례대로
- category : 쿼리 카테고리. 일반 쿼리(DML, DDL), commit, rollback, hint 등등
- elapsed : 쿼리 실행 시간
- connectionId : DB 커넥션 ID
- filterStack() : 해당 쿼리가 실행되기까지의 스택 트레이스
- formatSql() : 실행된 쿼리 정보
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit e69c6df. |
for (StackTraceElement element : stackTraces) { | ||
String trace = element.toString(); | ||
if (trace.startsWith(ROOT_PACKAGE) && !trace.contains(P6SPY_PACKAGE)) { | ||
sb.append("\n\t\t").append(order++).append(".").append(trace); | ||
} | ||
} |
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.
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.
수고하셨습니다~
decorator: | ||
datasource: | ||
p6spy: | ||
enable-logging: true |
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.
확인!
📌 개요 (필수)
🔨 작업 사항 (필수)
🌱 연관 내용 (선택)
p6spy는 datasource에 프록시로 붙어서 동작해요. spring-boot-starter를 이용해 보다 편리하게 사용할 수 있어요.
💻 실행 화면