aboutsummaryrefslogtreecommitdiff
path: root/plugin/autopath/metrics.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-10-15 19:39:24 +0200
committerGravatar GitHub <noreply@github.com> 2017-10-15 19:39:24 +0200
commit70ee39844e631fad3d0e28bac1a158a21da5ade5 (patch)
treef3badd3436cadc0670e99f9b065866f9ef944922 /plugin/autopath/metrics.go
parente34e2c251f236934b0d1928d521c35305dd3f389 (diff)
downloadcoredns-70ee39844e631fad3d0e28bac1a158a21da5ade5.tar.gz
coredns-70ee39844e631fad3d0e28bac1a158a21da5ade5.tar.zst
coredns-70ee39844e631fad3d0e28bac1a158a21da5ade5.zip
plugin/autopath: Add metrics and remove log line (#1143)
* plugin/autopath: Add namespace selector and metrics Add a namespace, so autopathing only is performed in this namespace. This will make caching work for the cluster again. Also export metrics that we've done a successful autopath * dont shadow * Fix * Back the namespacing changes
Diffstat (limited to 'plugin/autopath/metrics.go')
-rw-r--r--plugin/autopath/metrics.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugin/autopath/metrics.go b/plugin/autopath/metrics.go
new file mode 100644
index 000000000..3901fde3a
--- /dev/null
+++ b/plugin/autopath/metrics.go
@@ -0,0 +1,29 @@
+package autopath
+
+import (
+ "sync"
+
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+// Metrics for autopath.
+var (
+ AutoPathCount = prometheus.NewCounterVec(prometheus.CounterOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "autopath",
+ Name: "success_count_total",
+ Help: "Counter of requests that did autopath.",
+ }, []string{})
+)
+
+// OnStartupMetrics sets up the metrics on startup.
+func OnStartupMetrics() error {
+ metricsOnce.Do(func() {
+ prometheus.MustRegister(AutoPathCount)
+ })
+ return nil
+}
+
+var metricsOnce sync.Once