Skip to content

feat: 소비처 금액을 키 미터의 기간 지출로 (v0.72.0) - #119

Merged
yessjun merged 1 commit into
mainfrom
feat/consumer-metered-cost
Sep 7, 2026
Merged

feat: 소비처 금액을 키 미터의 기간 지출로 (v0.72.0)#119
yessjun merged 1 commit into
mainfrom
feat/consumer-metered-cost

Conversation

@yessjun

@yessjun yessjun commented Sep 7, 2026

Copy link
Copy Markdown
Member

📝 작업내용

  • 소비처 응답에 meteredCostUsd 추가: 공급자가 키마다 보고한 사용액에서 고른 기간의 몫만 뽑아 합친 금액
  • 계산은 llm_credit_usage_snapshots의 연속한 두 관측 차이이고, 보고값이 내려간 자리는 한도 창 리셋이라 새 값을 통째로 더함 (마지막에서 첫 값을 빼면 일어나지 않은 지출을 재게 됨)
  • 기간 시작 직전 관측이 기준선이고, 기준선이 없는 키는 그 키가 기간 안에 만들어진 경우에만 첫 관측을 통째로 셈
  • meteredObservedAt 추가: 그 소비처의 키 가운데 가장 오래된 대사 시각
  • attributedCostUsdpricedRequests는 응답에 유지 (모델별과 호출 종류별 표가 쓰는 출처이고, 공급자는 키 단위로만 알려 주므로 그 표들은 이 값밖에 쓸 수 없음)
  • 소비처 집계를 키별로 먼저 접은 뒤 차원별로 묶어, 일자 행 수만큼 금액이 곱해지지 않게 함
  • API 명세 v0.72.0, op 불변, 마이그레이션 없음

⭐️ 검증

  • mvn verify 1345건 통과
  • 신규 시험 둘: 한도 창 리셋을 건너 합계를 내는 것(1.5과 4.0 뒤 리셋해 3.25면 7.25), 기간 밖 지출을 세지 않는 것(같은 스냅샷에서 7일은 1.0, 30일은 7.0)
  • 자체 서빙만 쓴 소비처는 금액이 null이고 대사 시각도 null임을 함께 고정
  • ContractDriftTest 재생성 diff는 필드 둘과 설명 하나와 버전뿐

💬 리뷰 포인트

  • 기준선 없는 키의 첫 관측을 통째로 세는 조건을 「기간 안에 만들어진 키」로 좁혔음. 보존 90일을 넘겨 스냅샷이 지워진 오래된 키에서 과거 지출이 이 기간으로 딸려 오는 것을 막는 선택

A consumer's amount was the sum of per-request costs, which only start
where the gateway began sending them, so the column reported a fraction
of the spend and a count of the requests it could not price. The vendor
meters each key, and the difference between two readings is that key's
spend in the window whether or not we priced its requests. Readings that
drop are a limit-window reset, and the reconstruction adds the new
reading whole rather than measuring a spend that never happened.
@yessjun
yessjun merged commit fd756ca into main Sep 7, 2026
1 check passed
@yessjun
yessjun deleted the feat/consumer-metered-cost branch September 7, 2026 14:30
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.

1 participant