Skip to content

Commit

Permalink
reintroduce pprof
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Dec 9, 2024
1 parent 324bf9b commit d9fe4e0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/root/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package root
import (
"errors"
"fmt"
"net/http"
"net/http/pprof"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -61,6 +63,26 @@ func LoadConfig(scheme *runtime.Scheme, configFile string) (*configv1alpha1.Proj
func mergeOptionsFromFile(o manager.Options, cfg *configv1alpha1.ProjectConfig) manager.Options {
o = setLeaderElectionConfig(o, cfg.ControllerManagerConfigurationSpec)

if o.Metrics.BindAddress == "" && cfg.Metrics.BindAddress != "" {
o.Metrics.BindAddress = cfg.Metrics.BindAddress

endpoints := map[string]http.HandlerFunc{
"/debug/pprof/": pprof.Index,
"/debug/pprof/cmdline": pprof.Cmdline,
"/debug/pprof/profile": pprof.Profile,
"/debug/pprof/symbol": pprof.Symbol,
"/debug/pprof/trace": pprof.Trace,
}

if o.Metrics.ExtraHandlers == nil {
o.Metrics.ExtraHandlers = map[string]http.Handler{}
}

for path, handler := range endpoints {
o.Metrics.ExtraHandlers[path] = handler
}
}

if o.HealthProbeBindAddress == "" && cfg.Health.HealthProbeBindAddress != "" {
o.HealthProbeBindAddress = cfg.Health.HealthProbeBindAddress
}
Expand Down

0 comments on commit d9fe4e0

Please sign in to comment.