Repository navigation
feat(observability): expose net/http/pprof endpoints on an admin port - #843
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
📚 Docs preview✅ Live: https://pr-843-wavehouse-docs.wave-rf.workers.dev (follows this PR)
Earlier commits (2)
|
Code coverage overviewLanguages: Go Go
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…n-port-d3djaw # Conflicts: # AGENTS.md # CHANGELOG.md # docs/src/content/docs/configuration.mdx # docs/src/content/docs/deployment.md # docs/src/content/docs/development.md # internal/config/config.go # internal/config/defaults_test.go
|
@coderabbitai review |
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Requested by Taite · project thread
Summary
Before: to diagnose memory growth, a goroutine leak or a CPU hotspot in a running process, you had to rebuild it with debug instrumentation. WaveHouse exposed no
net/http/pprofendpoints.After: with
profiling.enabled: true(WH_PROFILING_ENABLED, defaultfalse), every process serves Go's pprof endpoints under/debug/pprof/onprofiling.addr(WH_PROFILING_ADDR, default127.0.0.1:6060). This applies to every process whatever its roles, and the listener is separate from the API port. Covered: heap, CPU, goroutine, allocs, threadcreate, block, mutex, the execution trace, cmdline and symbol. The endpoints are unauthenticated, so the default address is loopback.kubectl port-forwardstill reaches it. Boot logs aWARNfor any address that is not loopback.make devturns profiling on unlessWH_PROFILING_ENABLEDis already set.How:
observability.PprofHandlermounts pprof's handlers on a mux of its own. It is never added to the API router, and nothing serveshttp.DefaultServeMux, where the package's import also registers them.internal/app/wire_profiling.go(new) runs the listener through the existingserve. A bind failure is logged and not fatal, the same as the metrics sidecar.WriteTimeout, because pprof refuses a?seconds=longer than one.BaseContextis canceled as the drain begins, so a CPU profile or trace in flight ends then instead of holding the stop for the wholeserver.shutdown_timeout.config.Validaterefuses an address that is nothost:port, and a port that isserver.portor the enabled Prometheus sidecar's port.Call site in a shared file:
internal/app/app.gogains one line,a.wireProfiling(), at the end ofNew.wire.gois untouched, to stay clear of #712 and #770.Not included: block and mutex profiles return empty, because WaveHouse sets no sampling rate for either. The docs say so. Setting a rate would add a knob and runtime cost, so I left it for a follow-up if someone wants it.
Docs: configuration.mdx (new Profiling section, plus the YAML and env examples), deployment.md (new Profiling section with the commands), development.md (
make dev), architecture.md, AGENTS.md, config.yaml, CHANGELOG.Test plan
make build,go vet ./...go test -raceforinternal/config,internal/observabilityandinternal/app: config validation and warning cases, the default and zero-value cases, every pprof endpoint served, no other path served, the listener wired only when enabled, pprof returning 404 on the API router whether profiling is on or off, a live listener serving, a 60s CPU profile ending at the stop (this test fails without the shutdown cancel), and a bind failure that is not fatalship_it, docsship_itRelated Issues
Closes #143
Part of #777
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q9hHKxkKwmj22yP4Uu8fJR