aboutsummaryrefslogtreecommitdiff
path: root/plugin/metrics/metrics.go
diff options
context:
space:
mode:
authorGravatar James Hartig <fastest963@gmail.com> 2017-12-13 16:59:10 -0500
committerGravatar GitHub <noreply@github.com> 2017-12-13 16:59:10 -0500
commit1919913c986b7c1e1652a94bf69e54b503e40a18 (patch)
tree51ef8c36d4894736c920ac2151693b9a49c49708 /plugin/metrics/metrics.go
parent2e2e5e1bec11e4dc5a7862443a34965b65332e73 (diff)
downloadcoredns-1919913c986b7c1e1652a94bf69e54b503e40a18.tar.gz
coredns-1919913c986b7c1e1652a94bf69e54b503e40a18.tar.zst
coredns-1919913c986b7c1e1652a94bf69e54b503e40a18.zip
plugin/metrics: Added New func (#1309)
If external plugins wanted to extend metrics there was no way since zoneNames couldn't be initialized. Now plugins can call New to get an instance of Metrics that they can extend.
Diffstat (limited to 'plugin/metrics/metrics.go')
-rw-r--r--plugin/metrics/metrics.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/plugin/metrics/metrics.go b/plugin/metrics/metrics.go
index 0dabcdf96..df07da0ae 100644
--- a/plugin/metrics/metrics.go
+++ b/plugin/metrics/metrics.go
@@ -36,6 +36,11 @@ type Metrics struct {
zoneMu sync.RWMutex
}
+// New returns a new instance of Metrics with the given address
+func New(addr string) *Metrics {
+ return &Metrics{Addr: addr, zoneMap: make(map[string]bool)}
+}
+
// AddZone adds zone z to m.
func (m *Metrics) AddZone(z string) {
m.zoneMu.Lock()