From cc5afe27d0627156120d398fd0d67fe18828f8cf Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Tue, 31 Jan 2023 00:08:17 +0000 Subject: [PATCH 1/3] register pprof endpoints for allocator --- cmd/otel-allocator/server/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/otel-allocator/server/server.go b/cmd/otel-allocator/server/server.go index 8bd25a8ead..a1aee2f453 100644 --- a/cmd/otel-allocator/server/server.go +++ b/cmd/otel-allocator/server/server.go @@ -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/")) 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)) +} From 790df4c91369e8fd0996a8ce3f1c4e95b7aa2609 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Tue, 31 Jan 2023 21:26:16 +0000 Subject: [PATCH 2/3] changelog entry --- .chloggen/allocator-pprof.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 .chloggen/allocator-pprof.yaml diff --git a/.chloggen/allocator-pprof.yaml b/.chloggen/allocator-pprof.yaml new file mode 100755 index 0000000000..758010632f --- /dev/null +++ b/.chloggen/allocator-pprof.yaml @@ -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: From c88ec70fa654ffdc98e4a81163535363130e8a14 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Wed, 1 Feb 2023 18:53:50 +0000 Subject: [PATCH 3/3] full sentence for changelog --- .chloggen/allocator-pprof.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/allocator-pprof.yaml b/.chloggen/allocator-pprof.yaml index 758010632f..0f389d5b37 100755 --- a/.chloggen/allocator-pprof.yaml +++ b/.chloggen/allocator-pprof.yaml @@ -5,7 +5,7 @@ change_type: enhancement 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 +note: Register pprof endpoints under `/debug/pprof`. # One or more tracking issues related to the change issues: [188]