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>
This commit is contained in:
parent
88d94dc148
commit
7d542fec67
3 changed files with 13 additions and 3 deletions
2
plugin/cache/handler.go
vendored
2
plugin/cache/handler.go
vendored
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue