aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/handler.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-09-08 14:56:27 -0400
committerGravatar GitHub <noreply@github.com> 2022-09-08 14:56:27 -0400
commitb56b080a7c1125cd97c0a2edd7ae21bc1bdcd2a5 (patch)
tree1494a9542db6d6f69db39113734c8518a6701daf /plugin/cache/handler.go
parent1f0a41a66597cb8ab4aace8ea5b5bad880bcd23b (diff)
downloadcoredns-b56b080a7c1125cd97c0a2edd7ae21bc1bdcd2a5.tar.gz
coredns-b56b080a7c1125cd97c0a2edd7ae21bc1bdcd2a5.tar.zst
coredns-b56b080a7c1125cd97c0a2edd7ae21bc1bdcd2a5.zip
plugin/view: Advanced routing interface and new 'view' plugin (#5538)
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block. * add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/handler.go')
-rw-r--r--plugin/cache/handler.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go
index 3d2f43904..ec2135e8c 100644
--- a/plugin/cache/handler.go
+++ b/plugin/cache/handler.go
@@ -60,7 +60,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
cw := newPrefetchResponseWriter(server, state, c)
go c.doPrefetch(ctx, state, cw, i, now)
}
- servedStale.WithLabelValues(server, c.zonesMetricLabel).Inc()
+ servedStale.WithLabelValues(server, c.zonesMetricLabel, c.viewMetricLabel).Inc()
} else if c.shouldPrefetch(i, now) {
cw := newPrefetchResponseWriter(server, state, c)
go c.doPrefetch(ctx, state, cw, i, now)
@@ -89,7 +89,7 @@ func wildcardFunc(ctx context.Context) func() string {
}
func (c *Cache) doPrefetch(ctx context.Context, state request.Request, cw *ResponseWriter, i *item, now time.Time) {
- cachePrefetches.WithLabelValues(cw.server, c.zonesMetricLabel).Inc()
+ cachePrefetches.WithLabelValues(cw.server, c.zonesMetricLabel, c.viewMetricLabel).Inc()
c.doRefresh(ctx, state, cw)
// When prefetching we loose the item i, and with it the frequency
@@ -122,13 +122,13 @@ func (c *Cache) Name() string { return "cache" }
// 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, c.zonesMetricLabel).Inc()
+ cacheRequests.WithLabelValues(server, c.zonesMetricLabel, c.viewMetricLabel).Inc()
if i, ok := c.ncache.Get(k); ok {
itm := i.(*item)
ttl := itm.ttl(now)
if itm.matches(state) && (ttl > 0 || (c.staleUpTo > 0 && -ttl < int(c.staleUpTo.Seconds()))) {
- cacheHits.WithLabelValues(server, Denial, c.zonesMetricLabel).Inc()
+ cacheHits.WithLabelValues(server, Denial, c.zonesMetricLabel, c.viewMetricLabel).Inc()
return i.(*item)
}
}
@@ -136,11 +136,11 @@ func (c *Cache) getIgnoreTTL(now time.Time, state request.Request, server string
itm := i.(*item)
ttl := itm.ttl(now)
if itm.matches(state) && (ttl > 0 || (c.staleUpTo > 0 && -ttl < int(c.staleUpTo.Seconds()))) {
- cacheHits.WithLabelValues(server, Success, c.zonesMetricLabel).Inc()
+ cacheHits.WithLabelValues(server, Success, c.zonesMetricLabel, c.viewMetricLabel).Inc()
return i.(*item)
}
}
- cacheMisses.WithLabelValues(server, c.zonesMetricLabel).Inc()
+ cacheMisses.WithLabelValues(server, c.zonesMetricLabel, c.viewMetricLabel).Inc()
return nil
}