mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
perf(shared-state): batch calibrator counters with the usage write
Each served request spawned a second async write for the calibrator counters. They now ride the batch accountWith already sends, and only when shared state is on and a store is configured.
This commit is contained in:
@@ -1995,6 +1995,8 @@ type accountExtras struct {
|
||||
// with a store, accountWith mirrors it, and provenanceTokens, into the
|
||||
// shared month counters.
|
||||
provenance string
|
||||
// calibration is the shared token-calibrator counters of this call; accountWith adds them only with a store.
|
||||
calibration []counterIncr
|
||||
// promptCacheSaved is the micro-USD the provider prompt cache saved this call.
|
||||
promptCacheSaved int64
|
||||
provenanceTokens int64
|
||||
@@ -2229,6 +2231,10 @@ func (l *limiter) accountWith(scopes []limitScope, u usage, costMicros int64, x
|
||||
entries = append(entries, provenanceEntries(x.provider, x.provenance, x.provenanceTokens, wb.month)...)
|
||||
}
|
||||
|
||||
if l.store != nil && len(x.calibration) > 0 {
|
||||
entries = append(entries, x.calibration...)
|
||||
}
|
||||
|
||||
if x.hasLat && l.statsLatency {
|
||||
if x.provider != "" {
|
||||
entries = append(entries, latencyCounterEntries(kindProvider, x.provider, x.lat, wb, et)...)
|
||||
|
||||
Reference in New Issue
Block a user