Skip to content

feat(report): 리포트 생성 로그에 LLM 토큰 사용량 기록 추가#190

Open
1Seob wants to merge 7 commits into
developfrom
feat/report-token-usage-logging
Open

feat(report): 리포트 생성 로그에 LLM 토큰 사용량 기록 추가#190
1Seob wants to merge 7 commits into
developfrom
feat/report-token-usage-logging

Conversation

@1Seob

@1Seob 1Seob commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

📝 요약(Summary)

리포트 생성 로그에서 LLM 토큰 사용량을 추적할 수 있도록 report_generation_logs에 토큰 관련 컬럼을 추가하고,
일간·주간·월간·유형 리포트 생성 흐름에 Spring AI ChatResponse 기반 usage 기록을 연결했습니다.

주요 변경 사항

  • report_generation_logsinput_tokens, output_tokens, total_tokens, thinking_tokens 컬럼 추가
  • Spring AI ChatResponse에서 공통 토큰 사용량을 추출하는 LlmTokenUsage, LlmGenerationResult, LlmTokenUsageExtractor 추가
  • Gemini thoughtsTokenCountthinking_tokens로 분리 저장
  • 일간·주간·월간·유형 리포트 LLM 생성 단계에 토큰 사용량 기록 연결
  • rewrite 등 추가 LLM 호출이 발생하는 경우 토큰 사용량 합산 처리
  • 리포트 생성 로그 저장소, 서비스, listener 단위 테스트 보강

검증

  • compileJava
  • 관련 report log/service/listener/LLM client 테스트 실행
  • git diff --check

🔗 Related Issue

  • Closes:

💬 공유사항

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • PR 제목을 커밋 메시지 컨벤션에 맞게 작성했습니다.

1Seob added 7 commits July 8, 2026 15:21
report_generation_logs에 input_tokens, output_tokens, total_tokens 컬럼을 추가하고 ReportGenerationLog의 토큰
기록 경로를 확장함. ReportGenerationLogService와 ReportGenerationLogRecorder에서 별도 트랜잭션 기반 토큰 사용량 기록을 지원하며,
nullable usage 저장 케이스와 repository 매핑 테스트를 보강함
Spring AI ChatResponse의 Usage를 내부 LlmTokenUsage로 변환하는 공통 추출기를 추가하고, LLM 결과와 토큰 사용량을 함께 전달하기 위한
LlmGenerationResult를 추가함
DailyReportLlmClient가 Spring AI ChatResponse에서 본문과 Usage를 함께 추출하도록 변경하고, DailyReportService에서 생성 로그에
input/output/total token 사용량을 기록함
report_generation_logs에 thinking_tokens 컬럼을 추가하고 Spring AI GoogleGenAiUsage의 thoughtsTokenCount를
LlmTokenUsage로 추출하도록 확장함. 주간 리포트 생성과 rewrite usage를 합산해 기록
MonthlyReportLlmClient와 MonthlyReportLlmClientV2가 ChatResponse 기반으로 LLM 응답 본문과 토큰 사용량을 함께 반환하도록
변경하고, 월간 리포트 생성 로그에 input_tokens, output_tokens, total_tokens, thinking_tokens를 기록하도록 추가
유형 리포트의 Evidence Cards, Pattern Extraction, Type Selection, Content Generation 단계에서 ChatResponse 기반
토큰 사용량을 추출하고 각 generation log에 기록하도록 추가
유형 리포트의 단계별 LLM 토큰 사용량 기록 순서를 검증하고, 월간 V2 listener 테스트에서 토큰 기록 후 성공 처리 순서를 확인하도록 보강
@coldsunn

coldsunn commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

LGTM!

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