Skip to content

Commit fb9899e

Browse files
mackjmrjriguera
authored andcommitted
[exporter/datadogexporter, pkg/datadog, testbed] Use NewDefaultClientConfig instead of manually creating struct (open-telemetry#35519)
**Description:** This PR makes usage of `NewDefaultClientConfig` instead of manually creating the confighttp.ClientConfig struct. **Link to tracking Issue:** open-telemetry#35457
1 parent afa5709 commit fb9899e

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

exporter/datadogexporter/factory.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@ func NewFactory() exporter.Factory {
190190
}
191191

192192
func defaultClientConfig() confighttp.ClientConfig {
193-
// do not use NewDefaultClientConfig for backwards-compatibility
194-
return confighttp.ClientConfig{
195-
Timeout: 15 * time.Second,
196-
}
193+
client := confighttp.NewDefaultClientConfig()
194+
client.Timeout = 15 * time.Second
195+
return client
197196
}
198197

199198
// createDefaultConfig creates the default exporter configuration

pkg/datadog/config/config.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func validateClientConfig(cfg confighttp.ClientConfig) error {
147147
if cfg.Compression != "" {
148148
unsupported = append(unsupported, "compression")
149149
}
150-
if cfg.Headers != nil {
150+
if len(cfg.Headers) > 0 {
151151
unsupported = append(unsupported, "headers")
152152
}
153153
if cfg.HTTP2ReadIdleTimeout != 0 {
@@ -281,10 +281,9 @@ func (c *Config) Unmarshal(configMap *confmap.Conf) error {
281281
}
282282

283283
func defaultClientConfig() confighttp.ClientConfig {
284-
// do not use NewDefaultClientConfig for backwards-compatibility
285-
return confighttp.ClientConfig{
286-
Timeout: 15 * time.Second,
287-
}
284+
client := confighttp.NewDefaultClientConfig()
285+
client.Timeout = 15 * time.Second
286+
return client
288287
}
289288

290289
// CreateDefaultConfig creates the default exporter configuration

testbed/mockdatasenders/mockdatadogagentexporter/factory.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ func NewFactory() exporter.Factory {
3030

3131
// CreateDefaultConfig creates the default configuration for DDAPM Exporter
3232
func createDefaultConfig() component.Config {
33-
return &Config{
34-
ClientConfig: confighttp.ClientConfig{Endpoint: "localhost:8126"},
35-
}
33+
client := confighttp.NewDefaultClientConfig()
34+
client.Endpoint = "localhost:8126"
35+
return client
3636
}
3737

3838
func CreateTracesExporter(

0 commit comments

Comments
 (0)