Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(controller): Fixed broken pprof links #4037 #4038

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Organizations below are **officially** using Argo Rollouts. Please send a PR wit
1. [PagerDuty](https://www.pagerduty.com/)
1. [PayPal](https://www.paypal.com/)
1. [PayPay](https://paypay.ne.jp/)
1. [Plaid](https://plaid.com/)
1. [Priceline](https://priceline.com)
1. [Productboard](https://www.productboard.com)
1. [Quipper](https://www.quipper.com/)
Expand Down
17 changes: 7 additions & 10 deletions controller/profiling.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package controller

import (
"fmt"
"net/http"
"net/http/pprof"
)

const (
ProfilingPath = "/debug/pprof"
)

// NewPProfServer returns a new pprof server to gather runtime profiling data
func NewPProfServer() *http.ServeMux {
mux := http.NewServeMux()

mux.HandleFunc(ProfilingPath, pprof.Index)
mux.HandleFunc(fmt.Sprintf("%s/cmdline", ProfilingPath), pprof.Cmdline)
mux.HandleFunc(fmt.Sprintf("%s/profile", ProfilingPath), pprof.Profile)
mux.HandleFunc(fmt.Sprintf("%s/symbol", ProfilingPath), pprof.Symbol)
mux.HandleFunc(fmt.Sprintf("%s/trace", ProfilingPath), pprof.Trace)
// TODO: Remove enumerating all pprof endpoints if/when a more ergonomic
// attachment solution is introduced. See: https://github.com/golang/go/issues/71213.
mux.HandleFunc("/debug/pprof/", pprof.Index)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I believe this is the source of the bug. mux needs the trailing slash to match requests properly:

https://github.com/golang/go/blob/46b576be724b6e64359fd872b9bd5109aba93cc0/src/net/http/pprof/pprof.go#L95-L105

mux.HandleFunc("/debug/pprof/cmdline/", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile/", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol/", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace/", pprof.Trace)

return mux
}
Loading