Register metrics for custom-error-pages

Request count and timer weren't visible on /metrics endpoint since they
haven't been registered in prometheus DefaultRegister.
This commit is contained in:
Kornel Maleszka 2020-03-17 10:58:39 +01:00
parent 12bbdaaa53
commit 857c044144

View file

@ -27,6 +27,7 @@ import (
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@ -63,6 +64,11 @@ const (
ErrFilesPathVar = "ERROR_FILES_PATH"
)
func init() {
prometheus.MustRegister(requestCount)
prometheus.MustRegister(requestDuration)
}
func main() {
errFilesPath := "/www"
if os.Getenv(ErrFilesPathVar) != "" {