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) {
|
func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
uptimeGauge.Set(time.Since(h.startTime).Seconds())
|
uptimeGauge.Set(time.Since(h.startTime).Seconds())
|
||||||
|
|
||||||
h.promHandler.ServeHTTP(rw, req)
|
h.promHandler.ServeHTTP(rw, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
)
|
)
|
||||||
@ -21,12 +23,21 @@ var (
|
|||||||
Help: "Server health status",
|
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{
|
uptimeGauge = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "pgweb_uptime",
|
Name: "pgweb_uptime",
|
||||||
Help: "Server application uptime in seconds",
|
Help: "Server application uptime in seconds",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
startTimeGauge.Set(float64(time.Now().Unix()))
|
||||||
|
}
|
||||||
|
|
||||||
func IncrementQueriesCount() {
|
func IncrementQueriesCount() {
|
||||||
queriesCounter.Inc()
|
queriesCounter.Inc()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user