-
Notifications
You must be signed in to change notification settings - Fork 459
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
register pprof endpoints for allocator #1408
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) | ||
component: target allocator | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: register pprof endpoints under /debug/pprof | ||
|
||
# One or more tracking issues related to the change | ||
issues: [188] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"net/http/pprof" | ||
"net/url" | ||
"time" | ||
|
||
|
@@ -78,6 +79,7 @@ func NewServer(log logr.Logger, allocator allocation.Allocator, discoveryManager | |
router.GET("/jobs", s.JobHandler) | ||
router.GET("/jobs/:job_id/targets", s.TargetsHandler) | ||
router.GET("/metrics", gin.WrapH(promhttp.Handler())) | ||
registerPprof(router.Group("/debug/pprof/")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to design the registration in a way that the end point can be switched on and off? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any reason for it? E.g. perf penalty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I'm aware, just the import has no impact on performance. |
||
|
||
s.server = &http.Server{Addr: *listenAddr, Handler: router, ReadHeaderTimeout: 90 * time.Second} | ||
return s | ||
|
@@ -192,3 +194,11 @@ func GetAllTargetsByJob(allocator allocation.Allocator, job string) map[string]c | |
} | ||
return displayData | ||
} | ||
|
||
func registerPprof(g *gin.RouterGroup) { | ||
g.GET("/", gin.WrapF(pprof.Index)) | ||
g.GET("/cmdline", gin.WrapF(pprof.Cmdline)) | ||
g.GET("/profile", gin.WrapF(pprof.Profile)) | ||
g.GET("/symbol", gin.WrapF(pprof.Symbol)) | ||
g.GET("/trace", gin.WrapF(pprof.Trace)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please start the sentence with a capital
R
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done