Cache metrics server (#1746)

* plugin/cache: per server metrics

Use per server metrics in the cache plugin as well. This required
some plumbing changes. Also use request.Request more.

* fix cherry-pick
This commit is contained in:
Miek Gieben
2018-04-27 19:37:49 +01:00
committed by GitHub
parent 85f549b529
commit bfc647d4ed
5 changed files with 44 additions and 59 deletions

View File

@@ -102,7 +102,8 @@ func hash(qname string, qtype uint16, do bool) uint32 {
type ResponseWriter struct {
dns.ResponseWriter
*Cache
state request.Request
state request.Request
server string // Server handling the request.
prefetch bool // When true write nothing back to the client.
}
@@ -132,11 +133,11 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
if w.state.Match(res) {
w.set(res, key, mt, duration)
cacheSize.WithLabelValues(Success).Set(float64(w.pcache.Len()))
cacheSize.WithLabelValues(Denial).Set(float64(w.ncache.Len()))
cacheSize.WithLabelValues(w.server, Success).Set(float64(w.pcache.Len()))
cacheSize.WithLabelValues(w.server, Denial).Set(float64(w.ncache.Len()))
} else {
// Don't log it, but increment counter
cacheDrops.Inc()
cacheDrops.WithLabelValues(w.server).Inc()
}
}