Skip to content

[Feat/#218] Gemini LLM 호출 입력·출력·호출 횟수 로깅 - #219

Merged
tnals0924 merged 1 commit into
mainfrom
feat/#218-gemini-call-logging
Jul 17, 2026
Merged

[Feat/#218] Gemini LLM 호출 입력·출력·호출 횟수 로깅#219
tnals0924 merged 1 commit into
mainfrom
feat/#218-gemini-call-logging

Conversation

@tnals0924

Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

📝작업 내용

엑셀 분석 시 실제 Gemini LLM 호출의 input/output과 호출 횟수를 관찰할 수 있도록 로깅을 추가했다.

  • 카테고리 분류·이미지 매칭이 모두 거치는 단일 지점인 GeminiClient.requestText에 로그를 넣어, 두 종류의 호출을 한 곳에서 모두 잡는다.
  • 전역 AtomicInteger 카운터로 호출마다 순번(callNo)을 부여 → 로그만 보면 한 job에서 총 몇 번 호출됐는지 확인 가능.
  • 요청 시: model, systemInstruction(프롬프트), userContent(직렬화된 입력) 로깅
  • 응답 시: 소요시간(ms), 파싱 전 raw output 로깅
  • 실패 시: callNo, 소요시간, 예외 종류(ApiException/GenAiIOException) 로깅

💬리뷰 요구사항(선택)

  • 로그 레벨을 INFO로 뒀습니다. input/output이 길어 prod 로그 부담이 우려되면 DEBUG로 내리는 방안도 있습니다.
  • callCounter는 앱 전역이라 여러 job이 동시에 돌면 순번이 섞입니다. 지금은 "총 호출 횟수" 관찰이 목적이라 전역으로 뒀는데, job 단위로 분리(MDC에 jobId 등)가 필요하면 알려주세요.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

변경 사항

  • AI 클라이언트 레이어의 GeminiClient.requestText에 Gemini 호출 추적 로깅을 추가했습니다.
  • 전역 호출 카운터로 callNo를 부여하고, 요청 모델·프롬프트·사용자 콘텐츠와 응답 소요 시간·raw output을 기록합니다.
  • ApiException, GenAiIOException 발생 시 호출 번호와 소요 시간을 로깅한 뒤 기존 예외 처리 흐름을 유지합니다.

Walkthrough

GeminiClient가 Gemini 호출마다 순번을 부여하고 요청·응답 내용과 소요 시간을 기록한다. ApiExceptionGenAiIOException 발생 시 호출 정보와 소요 시간을 경고 로그로 남긴 뒤 기존 예외로 변환한다.

Changes

Gemini 호출 로깅

Layer / File(s) Summary
호출 추적 및 성공·실패 로깅
infrastructure/client/.../GeminiClient.kt
전역 호출 카운터와 로거를 추가하고, generateContent 호출의 순번·요청·응답·소요 시간을 기록한다. API 및 I/O 예외 로그에도 호출 순번과 소요 시간을 포함한다.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 [Feat/#218] 형식을 따르며 Gemini 호출 로깅 추가라는 변경 내용을 정확히 요약합니다.
Description check ✅ Passed 연관된 이슈, 작업 내용, 리뷰 요구사항이 모두 포함되어 있어 템플릿 요구사항을 대부분 충족합니다.
Linked Issues check ✅ Passed GeminiClient에 callNo, 요청/응답 로깅, 실패 시 예외별 로그가 추가되어 #218의 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 요약된 변경은 GeminiClient 로깅 추가에 한정되어 있어 범위를 벗어난 수정이 보이지 않습니다.
마이그레이션-엔티티 쌍 확인 ✅ Passed 변경 파일은 GeminiClient.kt만이라 JPA Entity/필드 변경이 없고, Flyway 마이그레이션 동반 여부 점검은 해당 없음입니다.
레이어 의존성 방향 확인 ✅ Passed 변경은 GeminiClient의 로깅 추가뿐이며, Service가 Repository/JpaRepository를 직접 주입받는 변경은 없습니다.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tnals0924
tnals0924 merged commit 17f2ea5 into main Jul 17, 2026
3 of 4 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6d4ca and a690d54.

📒 Files selected for processing (1)
  • infrastructure/client/src/main/kotlin/kr/dongchimi/client/ai/GeminiClient.kt

Comment on lines +79 to +83
logger.info {
"[Gemini] call #$callNo 요청 — model=${geminiProperties.model}\n" +
"--- systemInstruction ---\n$systemInstruction\n" +
"--- userContent ---\n$userContent"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini LLM 호출 입력·출력·호출 횟수 로깅

1 participant