mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 15:12:27 -08:00
Don't disable HTTP keep-alives for remote storage connections. (#3173)
Removes configurability introduced in #3160 in favour of hard-coding, per advice from @brian-brazil.
This commit is contained in:
parent
9c475b95db
commit
a03193232a
|
@ -520,8 +520,6 @@ type HTTPClientConfig struct {
|
||||||
ProxyURL URL `yaml:"proxy_url,omitempty"`
|
ProxyURL URL `yaml:"proxy_url,omitempty"`
|
||||||
// TLSConfig to use to connect to the targets.
|
// TLSConfig to use to connect to the targets.
|
||||||
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
|
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
// If set, override whether to use HTTP KeepAlive - scraping defaults OFF, remote read/write defaults ON
|
|
||||||
KeepAlive *bool `yaml:"keep_alive,omitempty"`
|
|
||||||
|
|
||||||
// Catches all undefined fields and must be empty after parsing.
|
// Catches all undefined fields and must be empty after parsing.
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
|
|
|
@ -52,12 +52,7 @@ type ClientConfig struct {
|
||||||
|
|
||||||
// NewClient creates a new Client.
|
// NewClient creates a new Client.
|
||||||
func NewClient(index int, conf *ClientConfig) (*Client, error) {
|
func NewClient(index int, conf *ClientConfig) (*Client, error) {
|
||||||
// If not specified in config, allow HTTP connections for remote API to use keep-alive
|
httpClient, err := httputil.NewClientFromConfigAndOptions(conf.HTTPClientConfig, false)
|
||||||
if conf.HTTPClientConfig.KeepAlive == nil {
|
|
||||||
val := true
|
|
||||||
conf.HTTPClientConfig.KeepAlive = &val
|
|
||||||
}
|
|
||||||
httpClient, err := httputil.NewClientFromConfig(conf.HTTPClientConfig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,16 @@ func NewClient(rt http.RoundTripper) *http.Client {
|
||||||
// NewClientFromConfig returns a new HTTP client configured for the
|
// NewClientFromConfig returns a new HTTP client configured for the
|
||||||
// given config.HTTPClientConfig.
|
// given config.HTTPClientConfig.
|
||||||
func NewClientFromConfig(cfg config.HTTPClientConfig) (*http.Client, error) {
|
func NewClientFromConfig(cfg config.HTTPClientConfig) (*http.Client, error) {
|
||||||
|
return NewClientFromConfigAndOptions(cfg, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClientFromConfigAndOptions returns a new HTTP client configured for the
|
||||||
|
// given config.HTTPClientConfig, optionally disabling HTTP keepalive.
|
||||||
|
func NewClientFromConfigAndOptions(cfg config.HTTPClientConfig, disableKeepAlives bool) (*http.Client, error) {
|
||||||
tlsConfig, err := NewTLSConfig(cfg.TLSConfig)
|
tlsConfig, err := NewTLSConfig(cfg.TLSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
disableKeepAlives := true // hard-coded default unless overridden in config
|
|
||||||
if cfg.KeepAlive != nil {
|
|
||||||
disableKeepAlives = !*cfg.KeepAlive
|
|
||||||
}
|
|
||||||
// The only timeout we care about is the configured scrape timeout.
|
// The only timeout we care about is the configured scrape timeout.
|
||||||
// It is applied on request. So we leave out any timings here.
|
// It is applied on request. So we leave out any timings here.
|
||||||
var rt http.RoundTripper = &http.Transport{
|
var rt http.RoundTripper = &http.Transport{
|
||||||
|
|
Loading…
Reference in a new issue