Querylog -- Implement file writing and update /querylog handler for changed structures.

This commit is contained in:
Eugene Bujak
2018-10-07 00:51:44 +03:00
parent 16fd1359cd
commit 2c33905a79
4 changed files with 255 additions and 32 deletions

View File

@@ -219,6 +219,7 @@ func setup(c *caddy.Controller) error {
return nil
})
c.OnShutdown(p.onShutdown)
c.OnFinalShutdown(p.onFinalShutdown)
return nil
}
@@ -250,6 +251,15 @@ func (p *plug) onShutdown() error {
return nil
}
func (p *plug) onFinalShutdown() error {
err := flushToFile(logBuffer)
if err != nil {
log.Printf("failed to flush to file: %s", err)
return err
}
return nil
}
type statsFunc func(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType)
func doDesc(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) {