-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Changes from all commits
8149cb8
c7091e0
dfd1fc6
49e21b7
5f5d8a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: breaking | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: datadogexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Remove config structs `LimitedClientConfig` and `LimitedTLSClientSettings`" | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [31733] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: This should have no impact to end users as long as they do not import Datadog exporter config structs in their source code. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [api] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: datadogexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Datadog exporter uses the same default HTTP settings as Datadog Agent HTTP transport | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [31733] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: datadogexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Datadog exporter respects a subset of settings in confighttp client configs | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [31733] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: "Currently the following configs are respected: `read_buffer_size`, `write_buffer_size`, `timeout`, `max_idle_conns`, `max_idle_conns_per_host`, `max_conns_per_host`, `idle_conn_timeout`, `disable_keep_alives` and `tls.insecure_skip_verify`." | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"strings" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/confighttp" | ||
"go.opentelemetry.io/collector/config/confignet" | ||
"go.opentelemetry.io/collector/config/configopaque" | ||
"go.opentelemetry.io/collector/config/configretry" | ||
|
@@ -390,24 +391,11 @@ type HostMetadataConfig struct { | |
Tags []string `mapstructure:"tags"` | ||
} | ||
|
||
// LimitedTLSClientSetting is a subset of TLSClientSetting, see LimitedClientConfig for more details | ||
type LimitedTLSClientSettings struct { | ||
// InsecureSkipVerify controls whether a client verifies the server's | ||
// certificate chain and host name. | ||
InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"` | ||
} | ||
|
||
type LimitedClientConfig struct { | ||
TLSSetting LimitedTLSClientSettings `mapstructure:"tls,omitempty"` | ||
} | ||
|
||
// Config defines configuration for the Datadog exporter. | ||
type Config struct { | ||
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. | ||
exporterhelper.QueueSettings `mapstructure:"sending_queue"` | ||
configretry.BackOffConfig `mapstructure:"retry_on_failure"` | ||
|
||
LimitedClientConfig `mapstructure:",squash"` | ||
confighttp.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. | ||
mx-psi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exporterhelper.QueueSettings `mapstructure:"sending_queue"` | ||
configretry.BackOffConfig `mapstructure:"retry_on_failure"` | ||
|
||
TagsConfig `mapstructure:",squash"` | ||
|
||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am undecided on whether this should be on There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
return err | ||
} | ||
|
||
if c.OnlyMetadata && (!c.HostMetadata.Enabled || c.HostMetadata.HostnameSource != HostnameSourceFirstResource) { | ||
return errNoMetadata | ||
} | ||
|
@@ -490,6 +482,36 @@ func (c *Config) Validate() error { | |
return nil | ||
} | ||
|
||
func validateClientConfig(cfg confighttp.ClientConfig) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A downside of this is that if new options are added to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
var unsupported []string | ||
if cfg.Auth != nil { | ||
unsupported = append(unsupported, "auth") | ||
} | ||
if cfg.Endpoint != "" { | ||
unsupported = append(unsupported, "endpoint") | ||
} | ||
if cfg.Compression != "" { | ||
unsupported = append(unsupported, "compression") | ||
} | ||
if cfg.ProxyURL != "" { | ||
unsupported = append(unsupported, "proxy_url") | ||
} | ||
if cfg.Headers != nil { | ||
unsupported = append(unsupported, "headers") | ||
} | ||
if cfg.HTTP2ReadIdleTimeout != 0 { | ||
unsupported = append(unsupported, "http2_read_idle_timeout") | ||
} | ||
if cfg.HTTP2PingTimeout != 0 { | ||
unsupported = append(unsupported, "http2_ping_timeout") | ||
} | ||
|
||
if len(unsupported) > 0 { | ||
return fmt.Errorf("these confighttp client configs are currently not respected by Datadog exporter: %s", strings.Join(unsupported, ", ")) | ||
} | ||
return nil | ||
} | ||
|
||
var _ error = (*renameError)(nil) | ||
|
||
// renameError is an error related to a renamed setting. | ||
|
There was a problem hiding this comment.
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
becauseTimeoutSettings.Timeout
andClientConfig.Timeout
have the same mapstructure key, which is not allowed. Same reason applies toLimitedClientConfig
/tls