Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exporter/datadogexporter/traces_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ func newTraceAgentConfig(ctx context.Context, params exporter.Settings, cfg *dat
acfg.PeerTags = cfg.Traces.PeerTags
acfg.MaxSenderRetries = 4
if traceCustomHTTPFeatureGate.IsEnabled() {
params.Logger.Info("Experimental feature: datadog exporter trace export uses a custom HTTP client from the exporter HTTP configs")
acfg.HTTPClientFunc = func() *http.Client {
return clientutil.NewHTTPClient(cfg.ClientConfig)
params.Logger.Info("Experimental feature: datadog exporter trace export uses a custom HTTP transport from the exporter HTTP configs")
acfg.HTTPTransportFunc = func() *http.Transport {
return clientutil.NewHTTPTransport(cfg.ClientConfig)
}
}
if !datadog.OperationAndResourceNameV2FeatureGate.IsEnabled() {
Expand Down
16 changes: 11 additions & 5 deletions internal/datadog/clientutil/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ var (

// NewHTTPClient returns a http.Client configured with a subset of the confighttp.ClientConfig options.
func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
return &http.Client{
Timeout: hcs.Timeout,
Transport: NewHTTPTransport(hcs),
}
}

// NewHTTPTransport returns a http.Transport configured with a subset of the confighttp.ClientConfig options.
func NewHTTPTransport(hcs confighttp.ClientConfig) *http.Transport {
// If the ProxyURL field in the configuration is set, the HTTP client will use the proxy.
// Otherwise, the HTTP client will use the system's proxy settings.
httpProxy := http.ProxyFromEnvironment
Expand All @@ -55,6 +63,7 @@ func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
// Not supported by intake
ForceAttemptHTTP2: false,
TLSClientConfig: &tls.Config{InsecureSkipVerify: hcs.TLS.InsecureSkipVerify},
DisableKeepAlives: hcs.DisableKeepAlives,
}
if hcs.ReadBufferSize > 0 {
transport.ReadBufferSize = hcs.ReadBufferSize
Expand All @@ -74,11 +83,8 @@ func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
if hcs.IdleConnTimeout > 0 {
transport.IdleConnTimeout = hcs.IdleConnTimeout
}
transport.DisableKeepAlives = hcs.DisableKeepAlives
return &http.Client{
Timeout: hcs.Timeout,
Transport: &transport,
}

return &transport
}

// SetExtraHeaders appends a header map to HTTP headers.
Expand Down
Loading