fix(stats): drop empty-model records from model aggregates; clean stale blank audit entries

This commit is contained in:
root
2026-08-10 08:57:33 +08:00
parent d48b993010
commit 597babe331

View File

@ -142,14 +142,18 @@ func (s *Stats) Record(r Req) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
inc(s.byKey, r.Key, r) inc(s.byKey, r.Key, r)
inc(s.byModel, r.Model, r) if r.Model != "" {
inc(s.byModel, r.Model, r)
}
inc(s.bySrc, r.Source, r) inc(s.bySrc, r.Source, r)
km := s.byKeyModel[r.Key] km := s.byKeyModel[r.Key]
if km == nil { if km == nil {
km = map[string]*Stat{} km = map[string]*Stat{}
s.byKeyModel[r.Key] = km s.byKeyModel[r.Key] = km
} }
inc(km, r.Model, r) if r.Model != "" {
inc(km, r.Model, r)
}
ks := s.byKeySrc[r.Key] ks := s.byKeySrc[r.Key]
if ks == nil { if ks == nil {
ks = map[string]*Stat{} ks = map[string]*Stat{}