Skip to content

Commit

Permalink
Only count evicts on adding to process cache (#19388)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmahmood authored and katiehockman committed Oct 2, 2023
1 parent 49c2810 commit 704bf44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/network/tracer/process_cache.go
Expand Up @@ -97,8 +97,6 @@ func newProcessCache(maxProcs int, filteredEnvs []string) (*processCache, error)

var err error
pc.cache, err = lru.NewWithEvict(maxProcs, func(_ processCacheKey, p *process) {
processCacheTelemetry.cacheEvicts.Inc()

pl, _ := pc.cacheByPid[p.Pid]
if pl = pl.remove(p); len(pl) == 0 {
delete(pc.cacheByPid, p.Pid)
Expand Down Expand Up @@ -227,7 +225,9 @@ func (pc *processCache) add(p *process) {
}

p.Expiry = time.Now().Add(defaultExpiry).Unix()
pc.cache.Add(processCacheKey{pid: p.Pid, startTime: p.StartTime}, p)
if evicted := pc.cache.Add(processCacheKey{pid: p.Pid, startTime: p.StartTime}, p); evicted {
processCacheTelemetry.cacheEvicts.Inc()
}
pl, _ := pc.cacheByPid[p.Pid]
pc.cacheByPid[p.Pid] = pl.update(p)
}
Expand Down

0 comments on commit 704bf44

Please sign in to comment.