Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make HTTP2 user visible #360

Merged
merged 1 commit into from Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions config/http_config.go
Expand Up @@ -28,7 +28,6 @@ import (
"net"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
Expand All @@ -43,6 +42,7 @@ import (
// DefaultHTTPClientConfig is the default HTTP client configuration.
var DefaultHTTPClientConfig = HTTPClientConfig{
FollowRedirects: true,
EnableHTTP2: true,
}

// defaultHTTPClientOptions holds the default HTTP client options.
Expand Down Expand Up @@ -198,6 +198,10 @@ type HTTPClientConfig struct {
// The omitempty flag is not set, because it would be hidden from the
// marshalled configuration when set to false.
FollowRedirects bool `yaml:"follow_redirects" json:"follow_redirects"`
// EnableHTTP2 specifies whether the client should configure HTTP2.
// The omitempty flag is not set, because it would be hidden from the
// marshalled configuration when set to false.
EnableHTTP2 bool `yaml:"enable_http2" json:"enable_http2"`
}

// SetDirectory joins any relative file paths with dir.
Expand Down Expand Up @@ -401,7 +405,7 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
ExpectContinueTimeout: 1 * time.Second,
DialContext: dialContext,
}
if opts.http2Enabled && os.Getenv("PROMETHEUS_COMMON_DISABLE_HTTP2") == "" {
if opts.http2Enabled && cfg.EnableHTTP2 {
// 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
Expand Down
1 change: 1 addition & 0 deletions config/testdata/http.conf.good.yml
Expand Up @@ -2,3 +2,4 @@ basic_auth:
username: username
password: "mysecret"
proxy_url: "http://remote.host"
enable_http2: true