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

enable pprof #1039

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import (
"context"
"flag"
"net/http"
"net/http/pprof"
"os"
"strings"

Expand Down Expand Up @@ -89,6 +91,7 @@
certSigningDisabled bool
certManagerEnabled bool
maxKafkaTopicConcurrentReconciles int
enableprofile bool
)

flag.StringVar(&namespaces, "namespaces", "", "Comma separated list of namespaces where operator listens for resources")
Expand All @@ -103,6 +106,7 @@
flag.BoolVar(&certManagerEnabled, "cert-manager-enabled", false, "Enable cert-manager integration")
flag.BoolVar(&certSigningDisabled, "disable-cert-signing-support", false, "Disable native certificate signing integration")
flag.IntVar(&maxKafkaTopicConcurrentReconciles, "max-kafka-topic-concurrent-reconciles", 10, "Define max amount of concurrent KafkaTopic reconciles")
flag.BoolVar(&enableprofile, "pprof", false, "Enable pprof")
flag.Parse()
ctrl.SetLogger(util.CreateLogger(verboseLogging, developmentLogging))

Expand Down Expand Up @@ -139,6 +143,14 @@
os.Exit(1)
}

if enableprofile {
mgr.AddMetricsExtraHandler("/debug/pprof/", http.HandlerFunc(pprof.Index))

Check failure on line 147 in main.go

View workflow job for this annotation

GitHub Actions / build

Error return value of `mgr.AddMetricsExtraHandler` is not checked (errcheck)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check the returned error here and for the other mgr.AddMetricsExtraHandler cases.

err = mgr.AddMetricsExtraHandler("/debug/pprof/", http.HandlerFunc(pprof.Index))
if err != nil {
	setupLog.Error(err, "unable to attach pprof to webserver")
	os.Exit(1)
}

mgr.AddMetricsExtraHandler("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))

Check failure on line 148 in main.go

View workflow job for this annotation

GitHub Actions / build

Error return value of `mgr.AddMetricsExtraHandler` is not checked (errcheck)
mgr.AddMetricsExtraHandler("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))

Check failure on line 149 in main.go

View workflow job for this annotation

GitHub Actions / build

Error return value of `mgr.AddMetricsExtraHandler` is not checked (errcheck)
mgr.AddMetricsExtraHandler("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
mgr.AddMetricsExtraHandler("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
}

if err := certv1.AddToScheme(mgr.GetScheme()); err != nil {
setupLog.Error(err, "")
os.Exit(1)
Expand Down
Loading