mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Metrics reload (#1586)
* wip * plugin/metrics: fix reload behavior Fixes #1472
This commit is contained in:
@@ -33,6 +33,8 @@ Extra labels used are:
|
||||
If monitoring is enabled, queries that do not enter the plugin chain are exported under the fake
|
||||
name "dropped" (without a closing dot - this is never a valid domain name).
|
||||
|
||||
This plugin can only be used once per Server Block.
|
||||
|
||||
## Syntax
|
||||
|
||||
~~~
|
||||
|
||||
@@ -103,13 +103,8 @@ func (m *Metrics) OnStartup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnShutdown tears down the metrics on shutdown and restart.
|
||||
func (m *Metrics) OnShutdown() error {
|
||||
if m.ln != nil {
|
||||
return m.ln.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// OnShutdown tears down the metrics listener on shutdown and restart.
|
||||
func (m *Metrics) OnShutdown() error { return m.ln.Close() }
|
||||
|
||||
func keys(m map[string]bool) []string {
|
||||
sx := []string{}
|
||||
|
||||
@@ -31,12 +31,12 @@ func setup(c *caddy.Controller) error {
|
||||
|
||||
for a, v := range uniqAddr.a {
|
||||
if v == todo {
|
||||
// During restarts we will keep this handler running, BUG.
|
||||
c.OncePerServerBlock(m.OnStartup)
|
||||
}
|
||||
uniqAddr.a[a] = done
|
||||
}
|
||||
c.OnFinalShutdown(m.OnShutdown)
|
||||
|
||||
c.OnShutdown(m.OnShutdown)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -48,10 +48,12 @@ func prometheusParse(c *caddy.Controller) (*Metrics, error) {
|
||||
uniqAddr.SetAddress(met.Addr)
|
||||
}()
|
||||
|
||||
i := 0
|
||||
for c.Next() {
|
||||
if len(met.ZoneNames()) > 0 {
|
||||
return met, c.Err("can only have one metrics module per server")
|
||||
if i > 0 {
|
||||
return nil, plugin.ErrOnce
|
||||
}
|
||||
i++
|
||||
|
||||
for _, z := range c.ServerBlockKeys {
|
||||
met.AddZone(plugin.Host(z).Normalize())
|
||||
|
||||
Reference in New Issue
Block a user