adding prometheus to frontend

This commit is contained in:
Yuri Grinshteyn 2019-06-14 15:29:41 -07:00
parent dc98b16a4d
commit 1636786a27

View file

@ -33,6 +33,8 @@ import (
"go.opencensus.io/stats/view" "go.opencensus.io/stats/view"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/prometheus/client_golang/prometheus/promhttp"
) )
const ( const (
@ -131,6 +133,7 @@ func main() {
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
r.HandleFunc("/robots.txt", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "User-agent: *\nDisallow: /") }) r.HandleFunc("/robots.txt", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "User-agent: *\nDisallow: /") })
r.HandleFunc("/_healthz", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "ok") }) r.HandleFunc("/_healthz", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "ok") })
r.HandleFunc("/metrics", promhttp.Handler())
var handler http.Handler = r var handler http.Handler = r
handler = &logHandler{log: log, next: handler} // add logging handler = &logHandler{log: log, next: handler} // add logging