Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Change pprof path #316

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cmds/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
e.JSONSerializer = new(serializer.DefaultJSONSerializer)

if config.Log.Level == enums.LogLevelDebug || config.Log.Level == enums.LogLevelTrace {
pprof.Register(e)
pprof.Register(e, consts.PprofPath)

Check warning on line 70 in pkg/cmds/distribution/distribution.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/distribution/distribution.go#L70

Added line #L70 was not covered by tests
}

handlers.InitializeDistribution(e)
Expand Down
7 changes: 3 additions & 4 deletions pkg/cmds/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@
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)

Check warning on line 92 in pkg/cmds/server/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/server/server.go#L92

Added line #L92 was not covered by tests
}
e.Use(middlewares.RedirectRepository(config))
e.JSONSerializer = new(serializer.DefaultJSONSerializer)

Check warning on line 95 in pkg/cmds/server/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/server/server.go#L94-L95

Added lines #L94 - L95 were not covered by tests

if !serverConfig.WithoutDistribution {
handlers.InitializeDistribution(e)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmds/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
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)

Check warning on line 62 in pkg/cmds/worker/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/worker/worker.go#L62

Added line #L62 was not covered by tests
}

go func() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const (
MaxWebhooks = 5
// ObsPresignMaxTtl
ObsPresignMaxTtl = time.Minute * 30
// PprofPath ...
PprofPath = "/__debug/pprof"
)

const (
Expand Down
3 changes: 3 additions & 0 deletions pkg/middlewares/redirect_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@
strings.HasSuffix(reqPath, ".svg")) {
return true
}
if strings.HasPrefix(reqPath, "/__debug") {
return true
}

Check warning on line 86 in pkg/middlewares/redirect_repository.go

View check run for this annotation

Codecov / codecov/patch

pkg/middlewares/redirect_repository.go#L84-L86

Added lines #L84 - L86 were not covered by tests
return false
}
Loading