mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-23 16:52:56 +00:00
28 lines
471 B
Go
28 lines
471 B
Go
package http
|
|
|
|
import (
|
|
"net/http"
|
|
"sync"
|
|
"time"
|
|
|
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
|
)
|
|
|
|
var (
|
|
defaultTransport *http.Transport
|
|
once sync.Once
|
|
)
|
|
|
|
func Transport() http.RoundTripper {
|
|
once.Do(func() {
|
|
t := http.DefaultTransport.(*http.Transport).Clone()
|
|
t.MaxIdleConns = 200
|
|
t.MaxIdleConnsPerHost = 100
|
|
t.IdleConnTimeout = 5 * time.Second
|
|
|
|
defaultTransport = t
|
|
})
|
|
|
|
return otelhttp.NewTransport(defaultTransport)
|
|
}
|