Skip to content

Commit 1d2be84

Browse files
dloucasfxatoulme
andauthored
[exporter/signalfx] Add an option to control the dimension client timeout (#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]>
1 parent 24f1c59 commit 1d2be84

File tree

8 files changed

+37
-1
lines changed

8 files changed

+37
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: signalfxexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add an option to control the dimension client timeout
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [27815]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

exporter/signalfxexporter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ The following configuration options can also be configured:
118118
- `max_idle_conns_per_host` (default = 20): The maximum idle HTTP connections the client can keep open per host.
119119
- `max_conns_per_host` (default = 20): The maximum total number of connections the client can keep open per host.
120120
- `idle_conn_timeout` (default = 30s): The maximum amount of time an idle connection will remain open before closing itself.
121+
- `timeout` (default = 10s): Amount of time to wait for the dimension HTTP request to complete.
121122
- `nonalphanumeric_dimension_chars`: (default = `"_-."`) A string of characters
122123
that are allowed to be used as a dimension key in addition to alphanumeric
123124
characters. Each nonalphanumeric dimension key character that isn't in this string

exporter/signalfxexporter/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ type DimensionClientConfig struct {
142142
MaxIdleConnsPerHost int `mapstructure:"max_idle_conns_per_host"`
143143
MaxConnsPerHost int `mapstructure:"max_conns_per_host"`
144144
IdleConnTimeout time.Duration `mapstructure:"idle_conn_timeout"`
145+
Timeout time.Duration `mapstructure:"timeout"`
145146
}
146147

147148
func (cfg *Config) getMetricTranslator(logger *zap.Logger) (*translation.MetricTranslator, error) {

exporter/signalfxexporter/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func TestLoadConfig(t *testing.T) {
7474
MaxIdleConnsPerHost: 20,
7575
MaxConnsPerHost: 20,
7676
IdleConnTimeout: 30 * time.Second,
77+
Timeout: 10 * time.Second,
7778
},
7879
TranslationRules: nil,
7980
ExcludeMetrics: nil,
@@ -140,6 +141,7 @@ func TestLoadConfig(t *testing.T) {
140141
MaxIdleConnsPerHost: 10,
141142
MaxConnsPerHost: 10000,
142143
IdleConnTimeout: 2 * time.Hour,
144+
Timeout: 20 * time.Second,
143145
},
144146
TranslationRules: []translation.Rule{
145147
{

exporter/signalfxexporter/exporter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func (se *signalfxExporter) start(ctx context.Context, host component.Host) (err
152152
MaxIdleConns: se.config.DimensionClient.MaxIdleConns,
153153
MaxIdleConnsPerHost: se.config.DimensionClient.MaxIdleConnsPerHost,
154154
IdleConnTimeout: se.config.DimensionClient.IdleConnTimeout,
155+
Timeout: se.config.DimensionClient.Timeout,
155156
})
156157
dimClient.Start()
157158

exporter/signalfxexporter/factory.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func NewFactory() exporter.Factory {
4646
func createDefaultConfig() component.Config {
4747
maxConnCount := defaultMaxConns
4848
idleConnTimeout := 30 * time.Second
49+
timeout := 10 * time.Second
4950

5051
return &Config{
5152
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
@@ -69,6 +70,7 @@ func createDefaultConfig() component.Config {
6970
MaxIdleConns: defaultDimMaxIdleConns,
7071
MaxIdleConnsPerHost: defaultDimMaxIdleConnsPerHost,
7172
IdleConnTimeout: idleConnTimeout,
73+
Timeout: timeout,
7274
},
7375
}
7476
}

exporter/signalfxexporter/internal/dimensions/dimclient.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ type DimensionClientOptions struct {
8080
MaxIdleConns int
8181
MaxIdleConnsPerHost int
8282
IdleConnTimeout time.Duration
83+
Timeout time.Duration
8384
}
8485

8586
// NewDimensionClient returns a new client
8687
func NewDimensionClient(ctx context.Context, options DimensionClientOptions) *DimensionClient {
8788
client := &http.Client{
88-
Timeout: 10 * time.Second,
89+
Timeout: options.Timeout,
8990
Transport: &http.Transport{
9091
Proxy: http.ProxyFromEnvironment,
9192
DialContext: (&net.Dialer{

exporter/signalfxexporter/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ signalfx/allsettings:
6969
max_idle_conns_per_host: 10
7070
max_conns_per_host: 10000
7171
idle_conn_timeout: 2h
72+
timeout: 20s
7273
exclude_properties:
7374
- property_name: globbed*
7475
- property_value: '!globbed*value'

0 commit comments

Comments
 (0)