diff options
author | 2017-10-08 04:30:44 -0700 | |
---|---|---|
committer | 2017-10-08 04:30:44 -0700 | |
commit | 7c6ba3fcbd78d8698b62925451b39cb103cbadbc (patch) | |
tree | b27370ba8bb9ac9f57d0b7823bba6f7f1d19f762 /plugin/proxy/proxy.go | |
parent | c1b9f74f98d2c3b65b026e8de06da7b1c4f41c7e (diff) | |
download | coredns-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.go | 9 |
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) } } |