diff options
author | 2016-10-28 12:54:49 +0100 | |
---|---|---|
committer | 2016-10-28 12:54:49 +0100 | |
commit | 54964653d10aa8b2e34ac21e007c701ceb456f7d (patch) | |
tree | 580ba3ee6491fcdfc1a1b70b2cf62dd8bd3a2726 /middleware/proxy/proxy.go | |
parent | ba26f47d5c65295342402d2c9996eb74884935e0 (diff) | |
download | coredns-54964653d10aa8b2e34ac21e007c701ceb456f7d.tar.gz coredns-54964653d10aa8b2e34ac21e007c701ceb456f7d.tar.zst coredns-54964653d10aa8b2e34ac21e007c701ceb456f7d.zip |
middleware/proxy: add request duration monitoring (#362)
Add a separate request duration metrics specially for proxying requests
upstream.
Fixes #259
Diffstat (limited to 'middleware/proxy/proxy.go')
-rw-r--r-- | middleware/proxy/proxy.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index aa58f4dbe..666430c9f 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -74,6 +74,9 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( for time.Now().Sub(start) < tryDuration { host := upstream.Select() if host == nil { + + RequestDuration.WithLabelValues(upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + return dns.RcodeServerFailure, errUnreachable } @@ -85,6 +88,9 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( if backendErr == nil { w.WriteMsg(reply) + + RequestDuration.WithLabelValues(upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + return 0, nil } timeout := host.FailTimeout @@ -97,6 +103,9 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( atomic.AddInt32(&host.Fails, -1) }(host, timeout) } + + RequestDuration.WithLabelValues(upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + return dns.RcodeServerFailure, errUnreachable } return p.Next.ServeDNS(ctx, w, r) |