feat(lps): 검색 1건 원가 계측 — AI 토큰·비용 + 시간 + 크롤 트래픽
검색이 소모하는 리소스/비용/시간을 잡 단위로 집계해 result.metrics 로 적재(API/FE 노출). 지금까진 타임스탬프만 있고 실제 비용 동인(AI 토큰·대역폭)은 버려지고 있었다. - services/metrics.SearchMetrics: duration_ms + ai(calls/tokens/est_cost_usd, gpt-4o-mini 단가) + crawl(fetches/html_bytes/malls_crawled) + source_ms - AI 클라이언트: resp.usage 를 last_usage 로 노출(그동안 폐기하던 토큰) - 어댑터: last_bytes(처리 HTML 바이트) 노출 — naver/coupang/browser_base 공통 - handler: 각 fetch 타이밍+바이트, AI 호출 토큰을 metrics 로 누적 → 결과에 스냅샷 - FE: 작업 카드에 원가 4타일(소요/AI비용/토큰/크롤 트래픽) - 테스트 2종. ⚠️ html_bytes 는 대역폭 근사(오픈마켓 리소스 미차단분 제외=하한), CDP 정확화는 백로그 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
61b9e6ae82
commit
69f6641c27
10 files changed
+168
-17
No files matched your search
+8
-1
@@ -81,11 +81,18 @@ curl -X POST localhost:9600/v1/lps/search -H 'Content-Type: application/json' \
|
||||
"shipping_fee": 0, "shipping_type": "rocket" },
|
||||
"top": [ /* 최저가 상위 N개 */ ],
|
||||
"sources": { "naver": {"count": 40}, "coupang": {"count": 40} },
|
||||
"stages": [ {"stage":"outlier","in":80,"out":76}, {"stage":"ai_match","in":76,"out":1}, {"stage":"top_n","in":1,"out":1} ]
|
||||
"stages": [ {"stage":"outlier","in":80,"out":76}, {"stage":"ai_match","in":76,"out":1}, {"stage":"top_n","in":1,"out":1} ],
|
||||
"metrics": { // 이 검색 1건이 쓴 리소스/비용/시간
|
||||
"duration_ms": 21500,
|
||||
"ai": { "calls": 2, "prompt_tokens": 5200, "completion_tokens": 180, "est_cost_usd": 0.000888 },
|
||||
"crawl": { "fetches": 3, "html_bytes": 1560000, "malls_crawled": ["gmarket"] },
|
||||
"source_ms": { "naver": 480, "coupang": 12300, "gmarket": 8700 }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
- `output.stages` = 각 단계에서 몇 건이 걸러졌는지(디버깅·품질 확인용).
|
||||
- `output.metrics` = 검색 1건의 원가. `ai`(호출·토큰·추정 비용$), `crawl`(fetch 수·처리 HTML 바이트·크롤한 몰), `source_ms`(소스별 소요), `duration_ms`(전체). ※ `html_bytes`는 처리한 응답 본문 기준(대역폭 근사) — 오픈마켓은 리소스 미차단이라 실제 대역폭보다 작다(하한).
|
||||
- 없는 job_id/잘못된 형식 → `result.desc = "LPS_JOB_NOT_FOUND"`.
|
||||
|
||||
> **⚠️ 가격의 의미 (배송비)**
|
||||
|
||||
Reference in new issue
Block a user