Skip to content

Commit

Permalink
Merge pull request #113 from telekom/feature/pprof
Browse files Browse the repository at this point in the history
Add possibility to enable pprof via config
  • Loading branch information
chdxD1 authored Apr 22, 2024
2 parents 3d073cb + 24c4ec5 commit 58beb58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func main() {
} else {
options = ctrl.Options{Scheme: scheme}
}

if options.MetricsBindAddress != "0" {
if options.MetricsBindAddress != "0" && options.MetricsBindAddress != "" {
err = initCollectors()
if err != nil {
setupLog.Error(err, "unable to initialize metrics collectors")
Expand Down
6 changes: 4 additions & 2 deletions pkg/managerconfig/managerconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
// Config holds internal config that is used to create manger.Options struct.
type Config struct {
Health HealthCfg `yaml:"health"`
Metrics MetricsCfg `yaml:"metrics"`
Metrics ServerConfig `yaml:"metrics"`
Pprof ServerConfig `yaml:"pprof"`
Webhook WebhookCfg `yaml:"webhook"`
LeaderElection LeaderElectionCfg `yaml:"leaderElection"`
}
Expand All @@ -24,7 +25,7 @@ type HealthCfg struct {
}

// MetricsCfg holds internal config for metrics options of manger.Options struct.
type MetricsCfg struct {
type ServerConfig struct {
BindAddress string `yaml:"bindAddress"`
}

Expand Down Expand Up @@ -68,6 +69,7 @@ func prepareManagerOptions(cfg *Config, scheme *runtime.Scheme) manager.Options
Scheme: scheme,
HealthProbeBindAddress: cfg.Health.HealthProbeBindAddress,
MetricsBindAddress: cfg.Metrics.BindAddress,
PprofBindAddress: cfg.Pprof.BindAddress,
WebhookServer: &webhook.DefaultServer{
Options: webhook.Options{
Port: cfg.Webhook.Port,
Expand Down

0 comments on commit 58beb58

Please sign in to comment.