Skip to content

Commit

Permalink
feat: add flag for pprof to be enabled or not
Browse files Browse the repository at this point in the history
  • Loading branch information
sesheffield committed Aug 7, 2024
1 parent c9c7dc7 commit 60f953c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Config struct {
HostnameToAccessControlAllowOriginValueMap map[string]string
PprofUsername string
PprofPassword string
EnablePprof bool
}

const (
Expand Down Expand Up @@ -132,6 +133,7 @@ const (
HOSTNAME_TO_ACCESS_CONTROL_ALLOW_ORIGIN_VALUE_MAP_ENVIRONMENT_KEY = "HOSTNAME_TO_ACCESS_CONTROL_ALLOW_ORIGIN_VALUE_MAP"
PPROF_USERNAME_ENVIRONMENT_KEY = "PPROF_USERNAME"
PPROF_PASSWORD_ENVIRONMENT_KEY = "PPROF_PASSWORD"
ENABLE_PPROF_ENVIRONMENT_KEY = "ENABLE_PPROF"
)

var (
Expand Down Expand Up @@ -398,6 +400,7 @@ func ReadConfig() Config {
HostnameToAccessControlAllowOriginValueMap: parsedHostnameToAccessControlAllowOriginValueMap,
PprofUsername: os.Getenv(PPROF_USERNAME_ENVIRONMENT_KEY),
PprofPassword: os.Getenv(PPROF_PASSWORD_ENVIRONMENT_KEY),
EnablePprof: EnvOrDefaultBool(ENABLE_PPROF_ENVIRONMENT_KEY, false),
}
}

Expand Down
4 changes: 3 additions & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func New(ctx context.Context, config config.Config, serviceLogger *logging.Servi

// create an http router for registering handlers for a given route
mux := http.NewServeMux()
registerPprofHandlers(config, mux)
if config.EnablePprof {
registerPprofHandlers(config, mux)
}

// AfterProxyFinalizer will run after the proxy middleware handler and is
// the final function called after all other middleware
Expand Down

0 comments on commit 60f953c

Please sign in to comment.