Skip to content

Commit

Permalink
[exporter/datadogexporter] Use NewDefaultClientConfig instead of manu…
Browse files Browse the repository at this point in the history
…ally creating struct

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

**Link to tracking Issue:** open-telemetry#35457
  • Loading branch information
mackjmr committed Oct 1, 2024
1 parent df53fdb commit cb0d4b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 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
7 changes: 3 additions & 4 deletions pkg/datadog/config/config.go
Original file line number Diff line number Diff line change
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: 5 additions & 1 deletion testbed/mockdatasenders/mockdatadogagentexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ func NewFactory() exporter.Factory {

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

return &Config{
ClientConfig: confighttp.ClientConfig{Endpoint: "localhost:8126"},
ClientConfig: client,
}
}

Expand Down

0 comments on commit cb0d4b4

Please sign in to comment.