Skip to content

Commit

Permalink
[exporter/datadogexporter, pkg/datadog, testbed] Use NewDefaultClient…
Browse files Browse the repository at this point in the history
…Config instead of manually creating struct (#35519)

**Description:**
This PR makes usage of `NewDefaultClientConfig` instead of manually
creating the confighttp.ClientConfig struct.

**Link to tracking Issue:** #35457
  • Loading branch information
mackjmr authored Oct 1, 2024
1 parent 6ec8e46 commit c621e78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,9 @@ func NewFactory() exporter.Factory {
}

func defaultClientConfig() confighttp.ClientConfig {
// do not use NewDefaultClientConfig for backwards-compatibility
return confighttp.ClientConfig{
Timeout: 15 * time.Second,
}
client := confighttp.NewDefaultClientConfig()
client.Timeout = 15 * time.Second
return client
}

// createDefaultConfig creates the default exporter configuration
Expand Down
9 changes: 4 additions & 5 deletions pkg/datadog/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func validateClientConfig(cfg confighttp.ClientConfig) error {
if cfg.Compression != "" {
unsupported = append(unsupported, "compression")
}
if cfg.Headers != nil {
if len(cfg.Headers) > 0 {
unsupported = append(unsupported, "headers")
}
if cfg.HTTP2ReadIdleTimeout != 0 {
Expand Down Expand Up @@ -281,10 +281,9 @@ func (c *Config) Unmarshal(configMap *confmap.Conf) error {
}

func defaultClientConfig() confighttp.ClientConfig {
// do not use NewDefaultClientConfig for backwards-compatibility
return confighttp.ClientConfig{
Timeout: 15 * time.Second,
}
client := confighttp.NewDefaultClientConfig()
client.Timeout = 15 * time.Second
return client
}

// CreateDefaultConfig creates the default exporter configuration
Expand Down
6 changes: 3 additions & 3 deletions testbed/mockdatasenders/mockdatadogagentexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func NewFactory() exporter.Factory {

// CreateDefaultConfig creates the default configuration for DDAPM Exporter
func createDefaultConfig() component.Config {
return &Config{
ClientConfig: confighttp.ClientConfig{Endpoint: "localhost:8126"},
}
client := confighttp.NewDefaultClientConfig()
client.Endpoint = "localhost:8126"
return client
}

func CreateTracesExporter(
Expand Down

0 comments on commit c621e78

Please sign in to comment.