Skip to content

feat: usage-recording/#266 - #267

Merged
hjbin-25 merged 9 commits into
mainfrom
feat/usage-recording/#266
Sep 23, 2026
Merged

hjbin-25 merged 9 commits into
mainfrom
feat/usage-recording/#266

Conversation

@hjbin-25

@hjbin-25 hjbin-25 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

변경 내용

스트리머 실사용(세션·방송)을 DB에 기록한다.

  • 세션·송출 이벤트 → usage_sessions / usage_broadcasts (신규 테이블만, 마이그레이션 000006 + AutoMigrate 등록)
  • 비동기 기록: 방송을 막지 않고, 일시 실패는 1·2·4초 재시도, 유실은 ERROR/WARN 로그로 드러냄
  • 탈퇴 시 user_id는 NULL(익명화), 비정상 종료로 열린 행은 기동 시 unclean_shutdown
  • 도구: cmd/usage-backfill(로그→SQL), scripts/usage/export-usage-logs.sh(필요 이벤트만 추출), report.sql(집계), grafana-dashboard.json

확인 방법

  • go build · go vet · go test ./..., -race(session·usage), DB 테스트는 TEST_DATABASE_URL
  • SQL 마이그레이션과 AutoMigrate 스키마 pg_dump 일치, 000006 down→up 왕복
  • 프로덕션 로그 백필: 세션 702 · 송출 172, 재적용해도 동일, 비밀값 0

데이터 보는 방법

  • 위치: 프로덕션 DB innolive. 서버에서 sudo -u postgres psql -d innolive, 또는 SSH 터널 ssh -p <SSH 포트> -N -L 15432:127.0.0.1:5432 <계정>@<서버>
  • 리포트: psql ... -f scripts/usage/report.sql — 3번(회차별)에 계정, 세션·방송 시작/종료, 방송 시간(일시정지 제외), 플랫폼, 직전 방송 이후 간격, 종료 분류(정상/연결 끊김/시스템 오류)
  • Grafana: grafana-dashboard.json Import. Postgres 연결(읽기 전용 계정·listen_addresses·pg_hba)은 root 설정 필요 — 상세 명령은 이 본문의 편집 기록 참고

배포 시

머지 = 프로덕션 배포이며, 기동 시 테이블이 생성된다. 배포 직후 과거분을 1회 백필한다.

INNOLIVE_SSH='-p <SSH 포트> <계정>@<서버>' scripts/usage/export-usage-logs.sh usage-events.jsonl
go run ./cmd/usage-backfill -until <배포 시각, RFC3339> < usage-events.jsonl > backfill.sql
# 서버로 올린 뒤: sudo -u postgres psql -d innolive -f backfill.sql

Closes #266

🤖 Generated with Claude Code

hjbin-25 and others added 9 commits September 23, 2026 10:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hjbin-25
hjbin-25 force-pushed the feat/usage-recording/#266 branch from 2d0df05 to 548c225 Compare September 23, 2026 01:43
@hjbin-25
hjbin-25 marked this pull request as ready for review September 23, 2026 01:45
@hjbin-25
hjbin-25 requested a review from a team as a code owner September 23, 2026 01:45
@hjbin-25
hjbin-25 merged commit 8514064 into main Sep 23, 2026
3 checks passed
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.

feat: 스트리머 실사용 기록을 DB에 남긴다

1 participant