aboutsummaryrefslogtreecommitdiff
path: root/plugin/dnssec/handler.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-12-27 15:48:14 +0000
committerGravatar GitHub <noreply@github.com> 2017-12-27 15:48:14 +0000
commit90dd4bbd4570560a4b72ca8525c99dc8fc1db163 (patch)
treeab7029569d9e281a28c6ab203a556176f6586eea /plugin/dnssec/handler.go
parent5ac42ed5c29609ce710c2d9a8e145919f4124c00 (diff)
downloadcoredns-90dd4bbd4570560a4b72ca8525c99dc8fc1db163.tar.gz
coredns-90dd4bbd4570560a4b72ca8525c99dc8fc1db163.tar.zst
coredns-90dd4bbd4570560a4b72ca8525c99dc8fc1db163.zip
metrics: correctly register all metrics (#1335)
After initial startup, see if prometheus is loaded and if so, register our metrics with it. Stop doing the init() func and just use the sync.Once so we don't double registrer our metrics.
Diffstat (limited to 'plugin/dnssec/handler.go')
-rw-r--r--plugin/dnssec/handler.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/plugin/dnssec/handler.go b/plugin/dnssec/handler.go
index 6fa2dd042..0fde35dd7 100644
--- a/plugin/dnssec/handler.go
+++ b/plugin/dnssec/handler.go
@@ -1,6 +1,8 @@
package dnssec
import (
+ "sync"
+
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/request"
@@ -42,28 +44,28 @@ func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
var (
cacheSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: plugin.Namespace,
- Subsystem: subsystem,
+ Subsystem: "dnssec",
Name: "cache_size",
Help: "The number of elements in the dnssec cache.",
}, []string{"type"})
cacheCapacity = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: plugin.Namespace,
- Subsystem: subsystem,
+ Subsystem: "dnssec",
Name: "cache_capacity",
Help: "The dnssec cache's capacity.",
}, []string{"type"})
cacheHits = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: plugin.Namespace,
- Subsystem: subsystem,
+ Subsystem: "dnssec",
Name: "cache_hits_total",
Help: "The count of cache hits.",
})
cacheMisses = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: plugin.Namespace,
- Subsystem: subsystem,
+ Subsystem: "dnssec",
Name: "cache_misses_total",
Help: "The count of cache misses.",
})
@@ -72,11 +74,4 @@ var (
// Name implements the Handler interface.
func (d Dnssec) Name() string { return "dnssec" }
-const subsystem = "dnssec"
-
-func init() {
- prometheus.MustRegister(cacheSize)
- prometheus.MustRegister(cacheCapacity)
- prometheus.MustRegister(cacheHits)
- prometheus.MustRegister(cacheMisses)
-}
+var once sync.Once