Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
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 @@ package main
import (
"context"
"flag"
"net/http"
"net/http/pprof"
"os"
"strings"

Expand Down Expand Up @@ -89,6 +91,7 @@ func main() {
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 @@ func main() {
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 @@ func main() {
os.Exit(1)
}

if enableprofile {
mgr.AddMetricsExtraHandler("/debug/pprof/", http.HandlerFunc(pprof.Index))
Copy link
Copy Markdown
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))
mgr.AddMetricsExtraHandler("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
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