From e0c7ad47ef61d17e878dc2a9c299788825b0cf71 Mon Sep 17 00:00:00 2001 From: Andreas Gerstmayr Date: Tue, 5 Sep 2023 18:21:26 +0300 Subject: [PATCH] Add pprof flag to optionally expose pprof data (#590) Resolves: #242 --- .chloggen/pprof.yaml | 16 ++++++++++++++++ cmd/start/main.go | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 .chloggen/pprof.yaml diff --git a/.chloggen/pprof.yaml b/.chloggen/pprof.yaml new file mode 100755 index 000000000..6f4cc64ed --- /dev/null +++ b/.chloggen/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, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add pprof flag to optionally expose pprof data + +# One or more tracking issues related to the change +issues: [242] + +# (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: diff --git a/cmd/start/main.go b/cmd/start/main.go index e7c01d1f7..684525fe8 100644 --- a/cmd/start/main.go +++ b/cmd/start/main.go @@ -31,6 +31,8 @@ func start(c *cobra.Command, args []string) { setupLog := ctrl.Log.WithName("setup") version := version.Get() + options.PprofBindAddress, _ = c.Flags().GetString("pprof-addr") + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") @@ -136,9 +138,11 @@ func addDependencies(mgr ctrl.Manager, ctrlConfig configv1alpha1.ProjectConfig, // NewStartCommand returns a new start command. func NewStartCommand() *cobra.Command { - return &cobra.Command{ + cmd := &cobra.Command{ Use: "start", Short: "Start the Tempo operator", Run: start, } + cmd.Flags().String("pprof-addr", "", "The address the pprof server binds to. Default is empty string which disables the pprof server.") + return cmd }