mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
Merge pull request #3052 from prometheus/connleak
Kill idle connections after 5 minutes
This commit is contained in:
commit
3519deae06
|
@ -420,6 +420,7 @@ func (s *targetScraper) scrape(ctx context.Context, w io.Writer) error {
|
|||
|
||||
s.req = req
|
||||
}
|
||||
|
||||
resp, err := ctxhttp.Do(ctx, s.client, s.req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -47,6 +47,9 @@ func NewClientFromConfig(cfg config.HTTPClientConfig) (*http.Client, error) {
|
|||
DisableKeepAlives: false,
|
||||
TLSClientConfig: tlsConfig,
|
||||
DisableCompression: true,
|
||||
// 5 minutes is typically above the maximum sane scrape interval. So we can
|
||||
// use keepalive for all configurations.
|
||||
IdleConnTimeout: 5 * time.Minute,
|
||||
}
|
||||
|
||||
// If a bearer token is provided, create a round tripper that will set the
|
||||
|
|
12
web/web.go
12
web/web.go
|
@ -346,8 +346,16 @@ func (h *Handler) Run(ctx context.Context) error {
|
|||
ReadTimeout: h.options.ReadTimeout,
|
||||
}
|
||||
|
||||
go httpSrv.Serve(httpl)
|
||||
go grpcSrv.Serve(grpcl)
|
||||
go func() {
|
||||
if err := httpSrv.Serve(httpl); err != nil {
|
||||
log.With("err", err).Warnf("error serving HTTP")
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
if err := grpcSrv.Serve(grpcl); err != nil {
|
||||
log.With("err", err).Warnf("error serving HTTP")
|
||||
}
|
||||
}()
|
||||
|
||||
return m.Serve()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue