diff options
author | 2021-03-21 08:58:16 -0700 | |
---|---|---|
committer | 2021-03-21 16:58:16 +0100 | |
commit | 5b9b079dabc7f71463cea3f0c6a92f338935039d (patch) | |
tree | f592af3c022675642e62e959b42803635799da26 /plugin/cache/cache.go | |
parent | ed3f287fe8114255739b2c1757a7621ba913244c (diff) | |
download | coredns-5b9b079dabc7f71463cea3f0c6a92f338935039d.tar.gz coredns-5b9b079dabc7f71463cea3f0c6a92f338935039d.tar.zst coredns-5b9b079dabc7f71463cea3f0c6a92f338935039d.zip |
Add cache eviction metrics to the cache plugin (#4411)
Signed-off-by: Frank Riley <fhriley@gmail.com>
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r-- | plugin/cache/cache.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index 2a56500a3..5673cc948 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -190,7 +190,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration switch mt { case response.NoError, response.Delegation: i := newItem(m, w.now(), duration) - w.pcache.Add(key, i) + if w.pcache.Add(key, i) { + evictions.WithLabelValues(w.server, Success).Inc() + } // when pre-fetching, remove the negative cache entry if it exists if w.prefetch { w.ncache.Remove(key) @@ -198,7 +200,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration case response.NameError, response.NoData, response.ServerError: i := newItem(m, w.now(), duration) - w.ncache.Add(key, i) + if w.ncache.Add(key, i) { + evictions.WithLabelValues(w.server, Denial).Inc() + } case response.OtherError: // don't cache these |