mirror of
https://github.com/coredns/coredns.git
synced 2025-12-06 10:25:10 -05:00
fix(metrics): add timeouts to metrics HTTP server (#7469)
Add ReadTimeout, WriteTimeout, and IdleTimeout (5s each) to metrics HTTP server and test to verify timeout behavior prevents hanging connections. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -98,7 +98,12 @@ func (m *Metrics) OnStartup() error {
|
||||
m.mux.Handle("/metrics", promhttp.HandlerFor(m.Reg, promhttp.HandlerOpts{}))
|
||||
|
||||
// creating some helper variables to avoid data races on m.srv and m.ln
|
||||
server := &http.Server{Handler: m.mux}
|
||||
server := &http.Server{
|
||||
Handler: m.mux,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
WriteTimeout: 5 * time.Second,
|
||||
IdleTimeout: 5 * time.Second,
|
||||
}
|
||||
m.srv = server
|
||||
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user