This commit is contained in:
Alex Sharov 2022-03-10 01:40:53 +07:00 committed by GitHub
parent e10506c933
commit a6577679d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -241,6 +241,7 @@ func StartPProf(address string, withMetrics bool) {
// from the registry into expvar, and execute regular expvar handler.
if withMetrics {
http.HandleFunc("/debug/metrics/prometheus", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
metrics2.WritePrometheus(w, true)
})
}

View File

@ -46,6 +46,7 @@ func ExpHandler(r metrics.Registry) http.Handler {
// This function enables metrics reporting separate from pprof.
func Setup(address string) {
http.HandleFunc("/debug/metrics/prometheus", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
metrics2.WritePrometheus(w, true)
})
//m.Handle("/debug/metrics", ExpHandler(metrics.DefaultRegistry))