Commit 6f3a7af5 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

Metrics reload (#1586)

* wip

* plugin/metrics: fix reload behavior

Fixes #1472
parent 5546dbf3
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment