Debug Options
Debug endpoint configuration options reference.
less than a minute
Debug Options
These options are used with WithDebugEndpoints():
app.WithDebugEndpoints(
app.WithPprofIf(os.Getenv("PPROF_ENABLED") == "true"),
)
Path Configuration
WithDebugPrefix
func WithDebugPrefix(prefix string) DebugOption
Mounts debug endpoints under a custom prefix.
Default: "/debug"
pprof Options
WithPprof
func WithPprof() DebugOption
Enables pprof endpoints unconditionally.
WithPprofIf
func WithPprofIf(condition bool) DebugOption
Conditionally enables pprof endpoints based on a boolean condition.
Available Endpoints
When pprof is enabled:
GET /debug/pprof/- Main pprof indexGET /debug/pprof/cmdline- Command lineGET /debug/pprof/profile- CPU profileGET /debug/pprof/symbol- Symbol lookupGET /debug/pprof/trace- Execution traceGET /debug/pprof/allocs- Memory allocationsGET /debug/pprof/block- Block profileGET /debug/pprof/goroutine- Goroutine profileGET /debug/pprof/heap- Heap profileGET /debug/pprof/mutex- Mutex profileGET /debug/pprof/threadcreate- Thread creation profile
Security Warning
⚠️ Never enable pprof in production without proper authentication. Debug endpoints expose sensitive runtime information.
Example
// Development: enable unconditionally
app.WithDebugEndpoints(
app.WithPprof(),
)
// Production: enable conditionally
app.WithDebugEndpoints(
app.WithDebugPrefix("/_internal/debug"),
app.WithPprofIf(os.Getenv("PPROF_ENABLED") == "true"),
)
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.