[Feat/#218] Gemini LLM 호출 입력·출력·호출 횟수 로깅 - #219
Conversation
📝 Walkthrough변경 사항
Walkthrough
ChangesGemini 호출 로깅
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt`:
- Around line 79-83: Update the request log in GeminiClient.kt lines 79-83 to
use a Kotlin raw multiline string with trimIndent() instead of + concatenation
and explicit \n characters; likewise update the response log in GeminiClient.kt
lines 93-96 to the same format, preserving all existing interpolated values and
log content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e9bcdbe6-36b5-4afb-b487-6ffd8701cf91
📒 Files selected for processing (1)
infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt
| logger.info { | ||
| "[Gemini] call #$callNo 요청 — model=${geminiProperties.model}\n" + | ||
| "--- systemInstruction ---\n$systemInstruction\n" + | ||
| "--- userContent ---\n$userContent" | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Kotlin의 다중 행 문자열(Raw String) 사용을 고려해 보세요.
현재 여러 줄의 로그 메시지를 작성할 때 + 연산자와 \n을 사용해 문자열을 결합하고 있습니다. Kotlin에서 제공하는 다중 행 문자열("""...""".trimIndent())을 활용하면 가독성을 높이고 더 깔끔하게 코드를 작성할 수 있습니다.
infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt#L79-L83: 요청 로그 문자열을"""...""".trimIndent()형태의 다중 행 문자열로 변경합니다.infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt#L93-L96: 응답 로그 문자열을"""...""".trimIndent()형태의 다중 행 문자열로 변경합니다.
💡 다중 행 문자열 적용 예시
요청 로그:
logger.info {
"""
[Gemini] call #$callNo 요청 — model=${geminiProperties.model}
--- systemInstruction ---
$systemInstruction
--- userContent ---
$userContent
""".trimIndent()
}응답 로그:
logger.info {
"""
[Gemini] call #$callNo 응답 — ${System.currentTimeMillis() - startedAt}ms
--- output ---
$text
""".trimIndent()
}📍 Affects 1 file
infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt#L79-L83(this comment)infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt#L93-L96
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt`
around lines 79 - 83, Update the request log in GeminiClient.kt lines 79-83 to
use a Kotlin raw multiline string with trimIndent() instead of + concatenation
and explicit \n characters; likewise update the response log in GeminiClient.kt
lines 93-96 to the same format, preserving all existing interpolated values and
log content.
#️⃣연관된 이슈
📝작업 내용
엑셀 분석 시 실제 Gemini LLM 호출의 input/output과 호출 횟수를 관찰할 수 있도록 로깅을 추가했다.
GeminiClient.requestText에 로그를 넣어, 두 종류의 호출을 한 곳에서 모두 잡는다.AtomicInteger카운터로 호출마다 순번(callNo)을 부여 → 로그만 보면 한 job에서 총 몇 번 호출됐는지 확인 가능.model,systemInstruction(프롬프트),userContent(직렬화된 입력) 로깅callNo, 소요시간, 예외 종류(ApiException/GenAiIOException) 로깅💬리뷰 요구사항(선택)
INFO로 뒀습니다. input/output이 길어 prod 로그 부담이 우려되면DEBUG로 내리는 방안도 있습니다.callCounter는 앱 전역이라 여러 job이 동시에 돌면 순번이 섞입니다. 지금은 "총 호출 횟수" 관찰이 목적이라 전역으로 뒀는데, job 단위로 분리(MDC에 jobId 등)가 필요하면 알려주세요.