diff options
author | 2018-04-18 09:42:20 +0100 | |
---|---|---|
committer | 2018-04-18 09:42:20 +0100 | |
commit | 08443a9f009fa0529a6d5cbb4708790165c16a0c (patch) | |
tree | ce8af5908e61dde11c271e025175aa9704adc926 /plugin/metrics/context.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/metrics/context.go')
-rw-r--r-- | plugin/metrics/context.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/plugin/metrics/context.go b/plugin/metrics/context.go index 4cce871f5..ac3010c71 100644 --- a/plugin/metrics/context.go +++ b/plugin/metrics/context.go @@ -1,7 +1,7 @@ package metrics import ( - "github.com/coredns/coredns/plugin" + "github.com/coredns/coredns/plugin/metrics/vars" "golang.org/x/net/context" ) @@ -15,10 +15,4 @@ import ( // Basic usage with a metric: // // <metric>.WithLabelValues(metrics.WithServer(ctx), labels..).Add(1) -func WithServer(ctx context.Context) string { - srv := ctx.Value(plugin.ServerCtx{}) - if srv == nil { - return "" - } - return srv.(string) -} +func WithServer(ctx context.Context) string { return vars.WithServer(ctx) } |