aboutsummaryrefslogtreecommitdiff
path: root/middleware/metrics/handler.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-10-04 11:05:04 +0100
committerGravatar GitHub <noreply@github.com> 2016-10-04 11:05:04 +0100
commitdb6c9a3f01c9bbef12fd2a1b43e5a84608044ee0 (patch)
treefab926dc9dab6152a7845313be034c5286d920bb /middleware/metrics/handler.go
parentd914832904760e8638bb79189822e2cbe84edee5 (diff)
downloadcoredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.tar.gz
coredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.tar.zst
coredns-db6c9a3f01c9bbef12fd2a1b43e5a84608044ee0.zip
middleware/metrics: fix crash on startup (#318)
Make the methods that handle Metrics all use pointer receivers to fix sync.Once not being initialized. Finish the setup_test to test for failures. And make the check for the address more strict and return an error when it does not have a port number. Add a toplevel test that starts a CoreDNS server with metrics enabled so we catch these errors in the future.
Diffstat (limited to 'middleware/metrics/handler.go')
-rw-r--r--middleware/metrics/handler.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/middleware/metrics/handler.go b/middleware/metrics/handler.go
index 2856621b5..a0247c517 100644
--- a/middleware/metrics/handler.go
+++ b/middleware/metrics/handler.go
@@ -13,7 +13,7 @@ import (
)
// ServeDNS implements the Handler interface.
-func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
+func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
state := request.Request{W: w, Req: r}
qname := state.QName()