Skip to content

Commit 06587f2

Browse files
authored
[exporter/datadog,pkg/datadog] Unembed confighttp structs (#49789)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Stops embedding `confighttp` structs on the `pkg/datadog` and `exporter/datadog` structs. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Test for open-telemetry/opentelemetry-collector/pull/15308. It is otherwise a noop. <!--Authorship attestation. See AGENTS.md for details. AI agents must not check this box on behalf of the user; the human author must check it themselves before the PR is ready for review.--> #### Authorship - [x] I, a human, wrote this pull request description myself. <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 02afa17 commit 06587f2

6 files changed

Lines changed: 19 additions & 19 deletions

File tree

exporter/datadogexporter/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ func (f *factory) createMetricsExporter(
306306
Metrics: cfg.Metrics,
307307
},
308308
TimeoutConfig: exporterhelper.TimeoutConfig{
309-
Timeout: cfg.Timeout,
309+
Timeout: cfg.ClientConfig.Timeout,
310310
},
311-
ClientConfig: cfg.TLS,
311+
ClientConfig: cfg.ClientConfig.TLS,
312312
QueueBatchConfig: cfg.QueueSettings,
313313
RetryConfig: cfg.BackOffConfig,
314314
API: cfg.API,

exporter/datadogexporter/hostmetadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func newMetadataConfigfromConfig(cfg *datadogconfig.Config) hostmetadata.PusherC
1818
MetricsEndpoint: cfg.Metrics.Endpoint,
1919
APIKey: string(cfg.API.Key),
2020
UseResourceMetadata: cfg.HostMetadata.HostnameSource == datadogconfig.HostnameSourceFirstResource,
21-
InsecureSkipVerify: cfg.TLS.InsecureSkipVerify,
21+
InsecureSkipVerify: cfg.ClientConfig.TLS.InsecureSkipVerify,
2222
ClientConfig: cfg.ClientConfig,
2323
RetrySettings: cfg.BackOffConfig,
2424
ReporterPeriod: cfg.HostMetadata.ReporterPeriod,

exporter/datadogexporter/traces_exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func newTraceAgentConfig(ctx context.Context, params exporter.Settings, cfg *dat
200200
acfg.Ignore["resource"] = cfg.Traces.IgnoreResources
201201
acfg.ReceiverEnabled = false // disable HTTP receiver
202202
acfg.AgentVersion = fmt.Sprintf("datadogexporter-%s-%s", params.BuildInfo.Command, params.BuildInfo.Version)
203-
acfg.SkipSSLValidation = cfg.TLS.InsecureSkipVerify
203+
acfg.SkipSSLValidation = cfg.ClientConfig.TLS.InsecureSkipVerify
204204
acfg.ComputeStatsBySpanKind = cfg.Traces.ComputeStatsBySpanKind
205205
acfg.PeerTagsAggregation = cfg.Traces.PeerTagsAggregation
206206
acfg.PeerTags = cfg.Traces.PeerTags

pkg/datadog/agentcomponents/agentcomponents.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ func setProxy(cfg *datadogconfig.Config, pkgconfig pkgconfigmodel.Config) {
276276
}
277277

278278
// proxy_url takes precedence over proxy environment variables if set
279-
if cfg.ProxyURL != "" {
280-
pkgconfig.Set("proxy.http", cfg.ProxyURL, pkgconfigmodel.SourceFile)
281-
pkgconfig.Set("proxy.https", cfg.ProxyURL, pkgconfigmodel.SourceFile)
279+
if cfg.ClientConfig.ProxyURL != "" {
280+
pkgconfig.Set("proxy.http", cfg.ClientConfig.ProxyURL, pkgconfigmodel.SourceFile)
281+
pkgconfig.Set("proxy.https", cfg.ClientConfig.ProxyURL, pkgconfigmodel.SourceFile)
282282
}
283283

284284
// If this is set to an empty []string, viper will have a type conflict when merging
@@ -294,8 +294,8 @@ func setProxy(cfg *datadogconfig.Config, pkgconfig pkgconfigmodel.Config) {
294294
}
295295

296296
func setTLSSetting(cfg *datadogconfig.Config, pkgconfig pkgconfigmodel.Config) {
297-
if cfg.TLS.InsecureSkipVerify {
298-
pkgconfig.Set("skip_ssl_validation", cfg.TLS.InsecureSkipVerify, pkgconfigmodel.SourceFile)
297+
if cfg.ClientConfig.TLS.InsecureSkipVerify {
298+
pkgconfig.Set("skip_ssl_validation", cfg.ClientConfig.TLS.InsecureSkipVerify, pkgconfigmodel.SourceFile)
299299
}
300300
}
301301

pkg/datadog/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type TagsConfig struct {
7373

7474
// Config defines configuration for the Datadog exporter.
7575
type Config struct {
76-
confighttp.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
76+
ClientConfig confighttp.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
7777
QueueSettings configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
7878
configretry.BackOffConfig `mapstructure:"retry_on_failure"`
7979

pkg/datadog/config/config_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ func TestUnmarshal(t *testing.T) {
300300
maxIdleConn := 300
301301
maxIdleConnPerHost := 150
302302
maxConnPerHost := 250
303-
cfgWithHTTPConfigs.ReadBufferSize = 100
304-
cfgWithHTTPConfigs.WriteBufferSize = 200
305-
cfgWithHTTPConfigs.Timeout = 10 * time.Second
306-
cfgWithHTTPConfigs.MaxIdleConns = maxIdleConn
307-
cfgWithHTTPConfigs.MaxIdleConnsPerHost = maxIdleConnPerHost
308-
cfgWithHTTPConfigs.MaxConnsPerHost = maxConnPerHost
309-
cfgWithHTTPConfigs.IdleConnTimeout = idleConnTimeout
310-
cfgWithHTTPConfigs.DisableKeepAlives = true
311-
cfgWithHTTPConfigs.TLS.InsecureSkipVerify = true
303+
cfgWithHTTPConfigs.ClientConfig.ReadBufferSize = 100
304+
cfgWithHTTPConfigs.ClientConfig.WriteBufferSize = 200
305+
cfgWithHTTPConfigs.ClientConfig.Timeout = 10 * time.Second
306+
cfgWithHTTPConfigs.ClientConfig.MaxIdleConns = maxIdleConn
307+
cfgWithHTTPConfigs.ClientConfig.MaxIdleConnsPerHost = maxIdleConnPerHost
308+
cfgWithHTTPConfigs.ClientConfig.MaxConnsPerHost = maxConnPerHost
309+
cfgWithHTTPConfigs.ClientConfig.IdleConnTimeout = idleConnTimeout
310+
cfgWithHTTPConfigs.ClientConfig.DisableKeepAlives = true
311+
cfgWithHTTPConfigs.ClientConfig.TLS.InsecureSkipVerify = true
312312
cfgWithHTTPConfigs.warnings = nil
313313

314314
tests := []struct {

0 commit comments

Comments
 (0)