Add process start time metric (#675)
This commit is contained in:
parent
52f7988ebd
commit
d4cfb059ce
@ -14,6 +14,7 @@ type Handler struct {
|
||||
|
||||
func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
uptimeGauge.Set(time.Since(h.startTime).Seconds())
|
||||
|
||||
h.promHandler.ServeHTTP(rw, req)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
@ -21,12 +23,21 @@ var (
|
||||
Help: "Server health status",
|
||||
})
|
||||
|
||||
startTimeGauge = promauto.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "pgweb_process_start_time",
|
||||
Help: "Server start time, seconds since unix epoch",
|
||||
})
|
||||
|
||||
uptimeGauge = promauto.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "pgweb_uptime",
|
||||
Help: "Server application uptime in seconds",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
startTimeGauge.Set(float64(time.Now().Unix()))
|
||||
}
|
||||
|
||||
func IncrementQueriesCount() {
|
||||
queriesCounter.Inc()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user