coredns querylog -- since we read entire querylog json once at startup, fill querylog cache from it and then rotate it on each incoming DNS query

This commit is contained in:
Eugene Bujak
2018-10-10 19:44:07 +03:00
parent a5d1053520
commit 5ae2a32d6e
3 changed files with 29 additions and 27 deletions

View File

@@ -223,6 +223,14 @@ func fillStatsFromQueryLog() error {
return err
}
queryLogLock.Lock()
queryLogCache = append(queryLogCache, entry)
if len(queryLogCache) > queryLogSize {
toremove := len(queryLogCache) - queryLogSize
queryLogCache = queryLogCache[toremove:]
}
queryLogLock.Unlock()
requests.IncWithTime(entry.Time)
if entry.Result.IsFiltered {
filtered.IncWithTime(entry.Time)