Overloaded (#1364)

* plugin/health: add 'overloaded metrics'

Query our on health endpoint and record (and export as a metric) the
time it takes. The Get has a 5s timeout, that, when reached, will set
the metric duration to 5s. The actually call "I'm I overloaded" is left
to an external entity.

* README

* golint and govet

* and the tests
This commit is contained in:
Miek Gieben
2018-01-10 11:41:22 +00:00
committed by GitHub
parent cced1a4c12
commit 48059a6c3e
5 changed files with 90 additions and 7 deletions

View File

@@ -21,9 +21,11 @@ type health struct {
h []Healther
sync.RWMutex
ok bool // ok is the global boolean indicating an all healthy plugin stack
stop chan bool
}
func (h *health) Startup() error {
func (h *health) OnStartup() error {
if h.Addr == "" {
h.Addr = defAddr
}
@@ -51,14 +53,20 @@ func (h *health) Startup() error {
go func() {
http.Serve(h.ln, h.mux)
}()
go func() {
h.overloaded()
}()
})
return nil
}
func (h *health) Shutdown() error {
func (h *health) OnShutdown() error {
if h.ln != nil {
return h.ln.Close()
}
h.stop <- true
return nil
}