diff options
author | 2018-04-18 09:42:20 +0100 | |
---|---|---|
committer | 2018-04-18 09:42:20 +0100 | |
commit | 08443a9f009fa0529a6d5cbb4708790165c16a0c (patch) | |
tree | ce8af5908e61dde11c271e025175aa9704adc926 /plugin/proxy/proxy.go | |
parent | 573ad62b770b7320f5499a1fc64a70b8f118e3b9 (diff) | |
download | coredns-08443a9f009fa0529a6d5cbb4708790165c16a0c.tar.gz coredns-08443a9f009fa0529a6d5cbb4708790165c16a0c.tar.zst coredns-08443a9f009fa0529a6d5cbb4708790165c16a0c.zip |
plugin/metrics: add 'server' label (#1682)
* plugin/metrics: add 'server' label
This uses the new WithServer(ctx) to get the current server from the
context.
First in a larger refactor to make all plugins do this.
* compile
* compile
* lala test
* compile and test
* typos
* Dont duplicate the code
Diffstat (limited to 'plugin/proxy/proxy.go')
-rw-r--r-- | plugin/proxy/proxy.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/plugin/proxy/proxy.go b/plugin/proxy/proxy.go index af61f424f..eae9953df 100644 --- a/plugin/proxy/proxy.go +++ b/plugin/proxy/proxy.go @@ -9,6 +9,7 @@ import ( "time" "github.com/coredns/coredns/plugin" + "github.com/coredns/coredns/plugin/metrics" "github.com/coredns/coredns/plugin/pkg/healthcheck" "github.com/coredns/coredns/request" @@ -87,7 +88,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( atomic.AddInt64(&host.Conns, 1) - RequestCount.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Add(1) + RequestCount.WithLabelValues(metrics.WithServer(ctx), state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Add(1) reply, backendErr = upstream.Exchanger().Exchange(ctx, host.Name, state) @@ -110,7 +111,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( w.WriteMsg(reply) - RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Observe(time.Since(start).Seconds()) + RequestDuration.WithLabelValues(metrics.WithServer(ctx), state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Observe(time.Since(start).Seconds()) return 0, taperr } |