Skip to content

Commit d5b415b

Browse files
authored
[exporter/datadog] Update HTTP configuration (#42896)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Use HTTPTransportFunc instead of the deprecated HTTPClientFunc. HTTPClientFunc was initially added to add support for custom transports on the opentelemetry exporter, but since datadog Agent 7.63 we can now use HTTPTransportFunc instead. This change will allow us to fully remove HTTPClientFunc on the agent, and further simplify the configuration options.
1 parent 41bceb3 commit d5b415b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

exporter/datadogexporter/traces_exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ func newTraceAgentConfig(ctx context.Context, params exporter.Settings, cfg *dat
207207
acfg.PeerTags = cfg.Traces.PeerTags
208208
acfg.MaxSenderRetries = 4
209209
if traceCustomHTTPFeatureGate.IsEnabled() {
210-
params.Logger.Info("Experimental feature: datadog exporter trace export uses a custom HTTP client from the exporter HTTP configs")
211-
acfg.HTTPClientFunc = func() *http.Client {
212-
return clientutil.NewHTTPClient(cfg.ClientConfig)
210+
params.Logger.Info("Experimental feature: datadog exporter trace export uses a custom HTTP transport from the exporter HTTP configs")
211+
acfg.HTTPTransportFunc = func() *http.Transport {
212+
return clientutil.NewHTTPTransport(cfg.ClientConfig)
213213
}
214214
}
215215
if !datadog.OperationAndResourceNameV2FeatureGate.IsEnabled() {

internal/datadog/clientutil/http.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ var (
3030

3131
// NewHTTPClient returns a http.Client configured with a subset of the confighttp.ClientConfig options.
3232
func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
33+
return &http.Client{
34+
Timeout: hcs.Timeout,
35+
Transport: NewHTTPTransport(hcs),
36+
}
37+
}
38+
39+
// NewHTTPTransport returns a http.Transport configured with a subset of the confighttp.ClientConfig options.
40+
func NewHTTPTransport(hcs confighttp.ClientConfig) *http.Transport {
3341
// If the ProxyURL field in the configuration is set, the HTTP client will use the proxy.
3442
// Otherwise, the HTTP client will use the system's proxy settings.
3543
httpProxy := http.ProxyFromEnvironment
@@ -55,6 +63,7 @@ func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
5563
// Not supported by intake
5664
ForceAttemptHTTP2: false,
5765
TLSClientConfig: &tls.Config{InsecureSkipVerify: hcs.TLS.InsecureSkipVerify},
66+
DisableKeepAlives: hcs.DisableKeepAlives,
5867
}
5968
if hcs.ReadBufferSize > 0 {
6069
transport.ReadBufferSize = hcs.ReadBufferSize
@@ -74,11 +83,8 @@ func NewHTTPClient(hcs confighttp.ClientConfig) *http.Client {
7483
if hcs.IdleConnTimeout > 0 {
7584
transport.IdleConnTimeout = hcs.IdleConnTimeout
7685
}
77-
transport.DisableKeepAlives = hcs.DisableKeepAlives
78-
return &http.Client{
79-
Timeout: hcs.Timeout,
80-
Transport: &transport,
81-
}
86+
87+
return &transport
8288
}
8389

8490
// SetExtraHeaders appends a header map to HTTP headers.

0 commit comments

Comments
 (0)