Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/datadog] Respect confighttp configs and use better defaults #31733

Merged
merged 5 commits into from
Mar 14, 2024

Conversation

songy23
Copy link
Member

@songy23 songy23 commented Mar 13, 2024

Description:
Datadog exporter respects a subset of settings in confighttp client configs and uses a consistent default HTTP transport settings as Datadog Agent (https://github.com/DataDog/datadog-agent/blob/f9ae7f4b842f83b23b2dfe3f15d31f9e6b12e857/pkg/util/http/transport.go#L91-L106).

@songy23 songy23 requested a review from dineshg13 March 13, 2024 17:55
@github-actions github-actions bot added the exporter/datadog Datadog components label Mar 13, 2024
@songy23 songy23 marked this pull request as ready for review March 13, 2024 18:12
@songy23 songy23 requested a review from a team March 13, 2024 18:12
// Config defines configuration for the Datadog exporter.
type Config struct {
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: need to get rid of TimeoutSettings because TimeoutSettings.Timeout and ClientConfig.Timeout have the same mapstructure key, which is not allowed. Same reason applies to LimitedClientConfig / tls

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be merged as-is but I left a couple of non-blocking comments

@@ -450,6 +438,10 @@ var _ component.Config = (*Config)(nil)

// Validate the configuration for errors. This is required by component.Config.
func (c *Config) Validate() error {
if err := validateClientConfig(c.ClientConfig); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am undecided on whether this should be on Unmarshal or on Validate, do you have a strong opinion on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly either. Those are valid (masharlable) confighttp options but we manually apply restriction from datadog exporter side, so I put it in Validate.

One benefit of putting in Unmarshal is that we can distinguish between not set vs. set to empty / 0, although I don't see it being very meaningful in this case.

@@ -490,6 +482,36 @@ func (c *Config) Validate() error {
return nil
}

func validateClientConfig(cfg confighttp.ClientConfig) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A downside of this is that if new options are added to confighttp.ClientConfig, they won't be caught by this check. I guess using reflection would work here, but it's a bit of a pain

Copy link
Member Author

@songy23 songy23 Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid using reflection too. In this case reflection also won't give us the mapstructure key, so we either can only return a generic error on new options or can only use the struct field name (which is different from mapstructure key), neither seems ideal.

@mx-psi mx-psi merged commit 135d723 into open-telemetry:main Mar 14, 2024
142 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 14, 2024
@songy23 songy23 deleted the ddog-http branch March 14, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/datadog Datadog components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants