mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 04:20:50 +08:00
refactor(logger): remove unnecessary request details limit logic
This commit is contained in:
@@ -87,10 +87,6 @@ type modelStats struct {
|
||||
Details []RequestDetail
|
||||
}
|
||||
|
||||
// maxDetailsPerModel limits the number of request details retained per model
|
||||
// to prevent unbounded memory growth. Oldest entries are dropped when exceeded.
|
||||
const maxDetailsPerModel = 1000
|
||||
|
||||
// RequestDetail stores the timestamp and token usage for a single request.
|
||||
type RequestDetail struct {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
@@ -225,11 +221,6 @@ func (s *RequestStatistics) updateAPIStats(stats *apiStats, model string, detail
|
||||
modelStatsValue.TotalRequests++
|
||||
modelStatsValue.TotalTokens += detail.Tokens.TotalTokens
|
||||
modelStatsValue.Details = append(modelStatsValue.Details, detail)
|
||||
// Prevent unbounded growth by dropping oldest entries when limit exceeded
|
||||
if len(modelStatsValue.Details) > maxDetailsPerModel {
|
||||
excess := len(modelStatsValue.Details) - maxDetailsPerModel
|
||||
modelStatsValue.Details = modelStatsValue.Details[excess:]
|
||||
}
|
||||
}
|
||||
|
||||
// Snapshot returns a copy of the aggregated metrics for external consumption.
|
||||
|
||||
Reference in New Issue
Block a user