aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/handler.go
diff options
context:
space:
mode:
authorGravatar Ben Kochie <superq@gmail.com> 2021-08-16 07:54:36 +0200
committerGravatar GitHub <noreply@github.com> 2021-08-16 13:54:36 +0800
commit7d542fec67fff55b1717d22881749893915a3ec2 (patch)
tree85cc100aa1d5be1162d464466dff684f7d76df00 /plugin/cache/handler.go
parent88d94dc148d91b8d629f0005163135ebc0810e82 (diff)
downloadcoredns-7d542fec67fff55b1717d22881749893915a3ec2.tar.gz
coredns-7d542fec67fff55b1717d22881749893915a3ec2.tar.zst
coredns-7d542fec67fff55b1717d22881749893915a3ec2.zip
Update cache metrics (#4781)
Add a total cache request counter to follow Prometheus conventions[0]. Mark the existing cache miss metric as deprecated. > Similarly, with hit or miss for caches, it’s better to have one > metric for total and another for hits. [0]: https://prometheus.io/docs/instrumenting/writing_exporters/#naming Signed-off-by: SuperQ <superq@gmail.com>
Diffstat (limited to 'plugin/cache/handler.go')
-rw-r--r--plugin/cache/handler.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go
index 2dd3c0646..418e4086a 100644
--- a/plugin/cache/handler.go
+++ b/plugin/cache/handler.go
@@ -91,6 +91,7 @@ func (c *Cache) Name() string { return "cache" }
func (c *Cache) get(now time.Time, state request.Request, server string) (*item, bool) {
k := hash(state.Name(), state.QType())
+ cacheRequests.WithLabelValues(server).Inc()
if i, ok := c.ncache.Get(k); ok && i.(*item).ttl(now) > 0 {
cacheHits.WithLabelValues(server, Denial).Inc()
@@ -108,6 +109,7 @@ func (c *Cache) get(now time.Time, state request.Request, server string) (*item,
// getIgnoreTTL unconditionally returns an item if it exists in the cache.
func (c *Cache) getIgnoreTTL(now time.Time, state request.Request, server string) *item {
k := hash(state.Name(), state.QType())
+ cacheRequests.WithLabelValues(server).Inc()
if i, ok := c.ncache.Get(k); ok {
ttl := i.(*item).ttl(now)