aboutsummaryrefslogtreecommitdiff
path: root/plugin/proxy/proxy.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-10-08 04:30:44 -0700
committerGravatar GitHub <noreply@github.com> 2017-10-08 04:30:44 -0700
commit7c6ba3fcbd78d8698b62925451b39cb103cbadbc (patch)
treeb27370ba8bb9ac9f57d0b7823bba6f7f1d19f762 /plugin/proxy/proxy.go
parentc1b9f74f98d2c3b65b026e8de06da7b1c4f41c7e (diff)
downloadcoredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.tar.gz
coredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.tar.zst
coredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.zip
plugin/proxy: fix metrics (#1137)
Add Counter metrics and fix duration to use upstream name (and only use it when we have one). Fix the documentation to reflect this. Fixes #1134
Diffstat (limited to '')
-rw-r--r--plugin/proxy/proxy.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/plugin/proxy/proxy.go b/plugin/proxy/proxy.go
index b2c713a53..f0e6eadad 100644
--- a/plugin/proxy/proxy.go
+++ b/plugin/proxy/proxy.go
@@ -80,9 +80,6 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
for time.Since(start) < tryDuration {
host := upstream.Select()
if host == nil {
-
- RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond))
-
return dns.RcodeServerFailure, fmt.Errorf("%s: %s", errUnreachable, "no upstream host")
}
@@ -94,6 +91,8 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
atomic.AddInt64(&host.Conns, 1)
queryEpoch := msg.Epoch()
+ RequestCount.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Add(1)
+
reply, backendErr = upstream.Exchanger().Exchange(ctx, host.Name, state)
respEpoch := msg.Epoch()
@@ -108,7 +107,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
if backendErr == nil {
w.WriteMsg(reply)
- RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond))
+ RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Observe(float64(time.Since(start) / time.Millisecond))
return 0, taperr
}
@@ -139,8 +138,6 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
}(host, timeout)
}
- RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond))
-
return dns.RcodeServerFailure, fmt.Errorf("%s: %s", errUnreachable, backendErr)
}
}