Skip to content

Commit 469eeb5

Browse files
committed
feat: use individual http.Server struct for metrics server
1 parent 343e2a6 commit 469eeb5

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

internal/prometheus/prometheus.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package prometheus
22

33
import (
44
"net/http"
5+
"time"
56

67
"github.com/VictoriaMetrics/metrics"
78
)
@@ -42,5 +43,14 @@ func StartPrometheusExporter(addr string) error {
4243
http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
4344
metrics.WritePrometheus(w, true)
4445
})
45-
return http.ListenAndServe(addr, nil)
46+
47+
server := &http.Server{
48+
Addr: addr,
49+
IdleTimeout: time.Minute,
50+
ReadTimeout: 10 * time.Second,
51+
ReadHeaderTimeout: 2 * time.Second,
52+
WriteTimeout: 10 * time.Second,
53+
}
54+
55+
return server.ListenAndServe()
4656
}

0 commit comments

Comments
 (0)