diff --git a/config/http_config.go b/config/http_config.go index 6c0c033d..6b3609a1 100644 --- a/config/http_config.go +++ b/config/http_config.go @@ -380,17 +380,18 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT ExpectContinueTimeout: 1 * time.Second, DialContext: dialContext, } - if opts.http2Enabled || os.Getenv("PROMETHEUS_COMMON_ENABLE_HTTP2") != "" { - // HTTP/2 support is golang has many problematic cornercases where + if opts.http2Enabled && os.Getenv("PROMETHEUS_COMMON_DISABLE_HTTP2") == "" { + // HTTP/2 support is golang had many problematic cornercases where // dead connections would be kept and used in connection pools. // https://github.com/golang/go/issues/32388 // https://github.com/golang/go/issues/39337 // https://github.com/golang/go/issues/39750 - // Enable HTTP2 if the environment variable - // PROMETHEUS_COMMON_ENABLE_HTTP2 is set. - // This is a temporary workaround so that users can safely test this - // and validate that HTTP2 can be enabled Prometheus-Wide again. + // Do not enable HTTP2 if the environment variable + // PROMETHEUS_COMMON_DISABLE_HTTP2 is set to a non-empty value. + // This allows users to easily disable HTTP2 in case they run into + // issues again, but will be removed once we are confident that + // things work as expected. http2t, err := http2.ConfigureTransports(rt.(*http.Transport)) if err != nil {