From 3b11648e14f44fed72da027bb51e7151216a3c5c Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 5 Sep 2018 21:21:46 +0300 Subject: [PATCH] Fix registration of metrics if querylog is enabled --- coredns_plugin/coredns_plugin.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coredns_plugin/coredns_plugin.go b/coredns_plugin/coredns_plugin.go index a2347cb7..6f675fd3 100644 --- a/coredns_plugin/coredns_plugin.go +++ b/coredns_plugin/coredns_plugin.go @@ -132,7 +132,7 @@ func setupPlugin(c *caddy.Controller) (*Plugin, error) { } case "querylog": d.QueryLogEnabled = true - once.Do(func() { + onceQueryLog.Do(func() { go startQueryLogServer() // TODO: how to handle errors? }) } @@ -184,7 +184,7 @@ func setup(c *caddy.Controller) error { }) c.OnStartup(func() error { - once.Do(func() { + onceMetrics.Do(func() { m := dnsserver.GetConfig(c).Handler("prometheus") if m == nil { return @@ -498,11 +498,11 @@ func (d *Plugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) // log if d.QueryLogEnabled { - logRequest(rrw.Msg, result, time.Since(start), ip) + logRequest(r, rrw.Msg, result, time.Since(start), ip) } return rcode, err } func (d *Plugin) Name() string { return "dnsfilter" } -var once sync.Once +var onceMetrics, onceQueryLog sync.Once