diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-11-21 18:41:02 +0300 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-11-21 18:41:02 +0300 |
commit | c5b6f4bae77c792a93622778f363f26478955f94 (patch) | |
tree | 5e938221a3550978b9c4d8283a83da6a4956d9ee | |
parent | c112d051165771d87b4e8158d5e39640d5fd8991 (diff) | |
parent | 6fe6aa58820eff11c5943911506cf4ae6c2c90c4 (diff) |
Merge branch 'an/profiling' into 'master'
Include pprof debug access in the Prometheus listener
Closes #707
See merge request gitlab-org/gitaly!442
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | cmd/gitaly/main.go | 3 | ||||
-rw-r--r-- | internal/server/pprof.go | 16 |
3 files changed, 21 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 00589bb45..5cf5fe081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ UNRELEASED +- Include pprof debug access in the Prometheus listener + https://gitlab.com/gitlab-org/gitaly/merge_requests/442 - Run gitaly-ruby in the same directory as gitaly https://gitlab.com/gitlab-org/gitaly/merge_requests/458 diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index e1f887a9c..79ed5a4df 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -130,6 +130,9 @@ func main() { log.WithField("address", config.Config.PrometheusListenAddr).Info("Starting prometheus listener") promMux := http.NewServeMux() promMux.Handle("/metrics", promhttp.Handler()) + + server.AddPprofHandlers(promMux) + go func() { http.ListenAndServe(config.Config.PrometheusListenAddr, promMux) }() diff --git a/internal/server/pprof.go b/internal/server/pprof.go new file mode 100644 index 000000000..ec99bf284 --- /dev/null +++ b/internal/server/pprof.go @@ -0,0 +1,16 @@ +package server + +import ( + "net/http" + "net/http/pprof" +) + +// AddPprofHandlers added profiling endpoints +func AddPprofHandlers(serveMux *http.ServeMux) { + // Register pprof handlers + serveMux.HandleFunc("/debug/pprof/", pprof.Index) + serveMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) + serveMux.HandleFunc("/debug/pprof/profile", pprof.Profile) + serveMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) + serveMux.HandleFunc("/debug/pprof/trace", pprof.Trace) +} |