Skip to content

Commit

Permalink
Add optional pprof to the manager pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Olshevski committed Jan 2, 2024
1 parent 7488fb8 commit 77b1cb4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import (
"context"
"flag"
"fmt"
"os"

"net/http"
_ "net/http/pprof"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -34,6 +38,15 @@ const (
ManagerLabelValue = "eno"
)

func init() {
go func() {
if addr := os.Getenv("PPROF_ADDR"); addr != "" {
err := http.ListenAndServe(addr, nil)
panic(fmt.Sprintf("unable to serve pprof listener: %s", err))
}
}()
}

type Options struct {
Rest *rest.Config
Namespace string
Expand Down

0 comments on commit 77b1cb4

Please sign in to comment.