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

Add an environment variable to enable HTTP2 #286

Merged
merged 1 commit into from Jul 23, 2021
Merged
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
14 changes: 10 additions & 4 deletions config/http_config.go
Expand Up @@ -27,6 +27,7 @@ import (
"net"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -379,18 +380,23 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
ExpectContinueTimeout: 1 * time.Second,
DialContext: dialContext,
}
if opts.http2Enabled {
if opts.http2Enabled || os.Getenv("PROMETHEUS_COMMON_ENABLE_HTTP2") != "" {
// HTTP/2 support is golang has 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
// TODO: Re-Enable HTTP/2 once upstream issue is fixed.
// TODO: use ForceAttemptHTTP2 when we move to Go 1.13+.
err := http2.ConfigureTransport(rt.(*http.Transport))

// 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.

http2t, err := http2.ConfigureTransports(rt.(*http.Transport))
if err != nil {
return nil, err
}
http2t.ReadIdleTimeout = time.Minute
}

// If a authorization_credentials is provided, create a round tripper that will set the
Expand Down