Skip to content

Commit 8d1c9f8

Browse files
author
Julien Pivotto
authored
Merge pull request #286 from roidelapluie/http2-env
Add an environment variable to enable HTTP2
2 parents 5f27aa2 + b5c3589 commit 8d1c9f8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

config/http_config.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"net"
2828
"net/http"
2929
"net/url"
30+
"os"
3031
"strings"
3132
"sync"
3233
"time"
@@ -379,18 +380,23 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
379380
ExpectContinueTimeout: 1 * time.Second,
380381
DialContext: dialContext,
381382
}
382-
if opts.http2Enabled {
383+
if opts.http2Enabled || os.Getenv("PROMETHEUS_COMMON_ENABLE_HTTP2") != "" {
383384
// HTTP/2 support is golang has many problematic cornercases where
384385
// dead connections would be kept and used in connection pools.
385386
// https://github.com/golang/go/issues/32388
386387
// https://github.com/golang/go/issues/39337
387388
// https://github.com/golang/go/issues/39750
388-
// TODO: Re-Enable HTTP/2 once upstream issue is fixed.
389-
// TODO: use ForceAttemptHTTP2 when we move to Go 1.13+.
390-
err := http2.ConfigureTransport(rt.(*http.Transport))
389+
390+
// Enable HTTP2 if the environment variable
391+
// PROMETHEUS_COMMON_ENABLE_HTTP2 is set.
392+
// This is a temporary workaround so that users can safely test this
393+
// and validate that HTTP2 can be enabled Prometheus-Wide again.
394+
395+
http2t, err := http2.ConfigureTransports(rt.(*http.Transport))
391396
if err != nil {
392397
return nil, err
393398
}
399+
http2t.ReadIdleTimeout = time.Minute
394400
}
395401

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

0 commit comments

Comments
 (0)