diff --git a/config/config.go b/config/config.go index fd18e19..89aa022 100644 --- a/config/config.go +++ b/config/config.go @@ -62,6 +62,7 @@ type Config struct { HostnameToAccessControlAllowOriginValueMap map[string]string PprofUsername string PprofPassword string + EnablePprof bool } const ( @@ -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 ( @@ -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), } } diff --git a/service/service.go b/service/service.go index fe84f43..e93e6b1 100644 --- a/service/service.go +++ b/service/service.go @@ -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