diff --git a/pkg/cmds/distribution/distribution.go b/pkg/cmds/distribution/distribution.go index c4850028..76d5997f 100644 --- a/pkg/cmds/distribution/distribution.go +++ b/pkg/cmds/distribution/distribution.go @@ -67,7 +67,7 @@ func Serve() error { e.JSONSerializer = new(serializer.DefaultJSONSerializer) if config.Log.Level == enums.LogLevelDebug || config.Log.Level == enums.LogLevelTrace { - pprof.Register(e) + pprof.Register(e, consts.PprofPath) } handlers.InitializeDistribution(e) diff --git a/pkg/cmds/server/server.go b/pkg/cmds/server/server.go index a23b2ce4..8b942917 100644 --- a/pkg/cmds/server/server.go +++ b/pkg/cmds/server/server.go @@ -88,12 +88,11 @@ func Serve(serverConfig ServerConfig) error { e.Use(echoprometheus.NewMiddleware(consts.AppName)) e.GET("/metrics", echoprometheus.NewHandler()) e.Use(middlewares.Healthz()) - e.Use(middlewares.RedirectRepository(config)) - e.JSONSerializer = new(serializer.DefaultJSONSerializer) - if config.Log.Level == enums.LogLevelDebug || config.Log.Level == enums.LogLevelTrace { - pprof.Register(e) + pprof.Register(e, consts.PprofPath) } + e.Use(middlewares.RedirectRepository(config)) + e.JSONSerializer = new(serializer.DefaultJSONSerializer) if !serverConfig.WithoutDistribution { handlers.InitializeDistribution(e) diff --git a/pkg/cmds/worker/worker.go b/pkg/cmds/worker/worker.go index b14a9794..9d80bfb9 100644 --- a/pkg/cmds/worker/worker.go +++ b/pkg/cmds/worker/worker.go @@ -59,7 +59,7 @@ func Worker() error { e.GET("/metrics", echoprometheus.NewHandler()) e.Use(middlewares.Healthz()) if config.Log.Level == enums.LogLevelDebug || config.Log.Level == enums.LogLevelTrace { - pprof.Register(e) + pprof.Register(e, consts.PprofPath) } go func() { diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index f63bd43f..d2ea623b 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -68,6 +68,8 @@ const ( MaxWebhooks = 5 // ObsPresignMaxTtl ObsPresignMaxTtl = time.Minute * 30 + // PprofPath ... + PprofPath = "/__debug/pprof" ) const ( diff --git a/pkg/middlewares/redirect_repository.go b/pkg/middlewares/redirect_repository.go index 2364307d..a3277634 100644 --- a/pkg/middlewares/redirect_repository.go +++ b/pkg/middlewares/redirect_repository.go @@ -81,5 +81,8 @@ func skipRedirect(c echo.Context) bool { strings.HasSuffix(reqPath, ".svg")) { return true } + if strings.HasPrefix(reqPath, "/__debug") { + return true + } return false }