Add http.Servers timeouts#1064
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the standalone pprof and metrics HTTP servers to use explicit http.Server instances with configured timeouts, and adds tests around the new server constructors and endpoint availability.
Changes:
- Replace
http.ListenAndServecalls with configuredhttp.Serverinstances for pprof and metrics endpoints. - Add
newPProfServer/newMetricsServerhelpers to centralize server configuration (address + timeouts). - Add/extend tests to validate timeouts and to confirm key endpoints are served.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
debug/flags.go |
Introduces newPProfServer and uses it from StartPProf to apply server timeouts. |
debug/flags_test.go |
Adds tests for newPProfServer and verifies pprof/metrics endpoints are reachable. |
cmd/sonicd/metrics/flags.go |
Introduces newMetricsServer and uses it from setupMetricsServer to apply server timeouts. |
cmd/sonicd/metrics/flags_test.go |
Adds a test ensuring newMetricsServer sets expected defaults (addr/handler/timeouts). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
... and 9 files with indirect coverage changes 🚀 New features to boost your workflow:
|
d9d372b to
873ebfb
Compare
thaarok
left a comment
There was a problem hiding this comment.
I am not sure if tests TestNewPProfServer_HasTimeouts and TestNewMetricsServer_SetsDefaultValues are meaningful, since they only tests assigning into a structure, but if it is required by the coverage requirements...
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
873ebfb to
92af295
Compare
This PR adds timeouts to the standalone pprof and metrics http.Servers.