Skip to content

Commit

Permalink
[exporter/signalfx] Add an option to control the dimension client tim…
Browse files Browse the repository at this point in the history
…eout (open-telemetry#27815)

**Description:** 
The dimension client timeout is currently hardcoded to 10 seconds, this
PR makes the timeout configurable.

Signed-off-by: Dani Louca <[email protected]>
Co-authored-by: Antoine Toulme <[email protected]>
  • Loading branch information
dloucasfx and atoulme committed Oct 20, 2023
1 parent 24f1c59 commit 1d2be84
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .chloggen/signalfx-exporter-add-dim-timeout.yaml
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: signalfxexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add an option to control the dimension client timeout

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27815]

# (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: []
1 change: 1 addition & 0 deletions exporter/signalfxexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The following configuration options can also be configured:
- `max_idle_conns_per_host` (default = 20): The maximum idle HTTP connections the client can keep open per host.
- `max_conns_per_host` (default = 20): The maximum total number of connections the client can keep open per host.
- `idle_conn_timeout` (default = 30s): The maximum amount of time an idle connection will remain open before closing itself.
- `timeout` (default = 10s): Amount of time to wait for the dimension HTTP request to complete.
- `nonalphanumeric_dimension_chars`: (default = `"_-."`) A string of characters
that are allowed to be used as a dimension key in addition to alphanumeric
characters. Each nonalphanumeric dimension key character that isn't in this string
Expand Down
1 change: 1 addition & 0 deletions exporter/signalfxexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ type DimensionClientConfig struct {
MaxIdleConnsPerHost int `mapstructure:"max_idle_conns_per_host"`
MaxConnsPerHost int `mapstructure:"max_conns_per_host"`
IdleConnTimeout time.Duration `mapstructure:"idle_conn_timeout"`
Timeout time.Duration `mapstructure:"timeout"`
}

func (cfg *Config) getMetricTranslator(logger *zap.Logger) (*translation.MetricTranslator, error) {
Expand Down
2 changes: 2 additions & 0 deletions exporter/signalfxexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestLoadConfig(t *testing.T) {
MaxIdleConnsPerHost: 20,
MaxConnsPerHost: 20,
IdleConnTimeout: 30 * time.Second,
Timeout: 10 * time.Second,
},
TranslationRules: nil,
ExcludeMetrics: nil,
Expand Down Expand Up @@ -140,6 +141,7 @@ func TestLoadConfig(t *testing.T) {
MaxIdleConnsPerHost: 10,
MaxConnsPerHost: 10000,
IdleConnTimeout: 2 * time.Hour,
Timeout: 20 * time.Second,
},
TranslationRules: []translation.Rule{
{
Expand Down
1 change: 1 addition & 0 deletions exporter/signalfxexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (se *signalfxExporter) start(ctx context.Context, host component.Host) (err
MaxIdleConns: se.config.DimensionClient.MaxIdleConns,
MaxIdleConnsPerHost: se.config.DimensionClient.MaxIdleConnsPerHost,
IdleConnTimeout: se.config.DimensionClient.IdleConnTimeout,
Timeout: se.config.DimensionClient.Timeout,
})
dimClient.Start()

Expand Down
2 changes: 2 additions & 0 deletions exporter/signalfxexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func NewFactory() exporter.Factory {
func createDefaultConfig() component.Config {
maxConnCount := defaultMaxConns
idleConnTimeout := 30 * time.Second
timeout := 10 * time.Second

return &Config{
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
Expand All @@ -69,6 +70,7 @@ func createDefaultConfig() component.Config {
MaxIdleConns: defaultDimMaxIdleConns,
MaxIdleConnsPerHost: defaultDimMaxIdleConnsPerHost,
IdleConnTimeout: idleConnTimeout,
Timeout: timeout,
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion exporter/signalfxexporter/internal/dimensions/dimclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ type DimensionClientOptions struct {
MaxIdleConns int
MaxIdleConnsPerHost int
IdleConnTimeout time.Duration
Timeout time.Duration
}

// NewDimensionClient returns a new client
func NewDimensionClient(ctx context.Context, options DimensionClientOptions) *DimensionClient {
client := &http.Client{
Timeout: 10 * time.Second,
Timeout: options.Timeout,
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Expand Down
1 change: 1 addition & 0 deletions exporter/signalfxexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ signalfx/allsettings:
max_idle_conns_per_host: 10
max_conns_per_host: 10000
idle_conn_timeout: 2h
timeout: 20s
exclude_properties:
- property_name: globbed*
- property_value: '!globbed*value'
Expand Down

0 comments on commit 1d2be84

Please sign in to comment.