Skip to content

Commit

Permalink
[chore] deprecate signalfxexporter max_connections warning (#17406)
Browse files Browse the repository at this point in the history
We now have a better way to set up the http client settings, but we need to finish deprecating the `max_connections` config option. This commit removes the use of MaxConnections and adds a warning if it is explicitly used.

Co-authored-by: Dmitrii Anoshin <[email protected]>
  • Loading branch information
atoulme and dmitryax authored Jan 6, 2023
1 parent 3fadc47 commit 647ce4f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion exporter/signalfxexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ exporters:
dot.test: test
realm: us1
timeout: 5s
max_connections: 80
max_idle_conns: 80
```

> :warning: When enabling the SignalFx receiver or exporter, configure both the `metrics` and `logs` pipelines.
Expand Down
9 changes: 6 additions & 3 deletions exporter/signalfxexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func TestLoadConfig(t *testing.T) {
require.NoError(t, err)
defaultCfg.TranslationRules = defaultTranslationRules

seventy := 70

tests := []struct {
id component.ID
expected component.Config
Expand All @@ -59,14 +61,15 @@ func TestLoadConfig(t *testing.T) {
{
id: component.NewIDWithName(typeStr, "allsettings"),
expected: &Config{
AccessToken: "testToken",
Realm: "us1",
MaxConnections: 70,
AccessToken: "testToken",
Realm: "us1",
HTTPClientSettings: confighttp.HTTPClientSettings{Timeout: 2 * time.Second,
Headers: map[string]configopaque.String{
"added-entry": "added value",
"dot.test": "test",
},
MaxIdleConns: &seventy,
MaxIdleConnsPerHost: &seventy,
},
RetrySettings: exporterhelper.RetrySettings{
Enabled: true,
Expand Down
13 changes: 8 additions & 5 deletions exporter/signalfxexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,14 @@ func (se *signalfxExporter) startLogs(_ context.Context, host component.Host) er
func (se *signalfxExporter) createClient(host component.Host) (*http.Client, error) {
se.config.HTTPClientSettings.TLSSetting = se.config.IngestTLSSettings

if se.config.HTTPClientSettings.MaxIdleConns == nil {
se.config.HTTPClientSettings.MaxIdleConns = &se.config.MaxConnections
}
if se.config.HTTPClientSettings.MaxIdleConnsPerHost == nil {
se.config.HTTPClientSettings.MaxIdleConnsPerHost = &se.config.MaxConnections
if se.config.MaxConnections != 0 && (se.config.MaxIdleConns == nil || se.config.HTTPClientSettings.MaxIdleConnsPerHost == nil) {
se.logger.Warn("You are using the deprecated `max_connections` option that will be removed soon; use `max_idle_conns` and/or `max_idle_conns_per_host` instead: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/signalfxexporter#advanced-configuration")
if se.config.HTTPClientSettings.MaxIdleConns == nil {
se.config.HTTPClientSettings.MaxIdleConns = &se.config.MaxConnections
}
if se.config.HTTPClientSettings.MaxIdleConnsPerHost == nil {
se.config.HTTPClientSettings.MaxIdleConnsPerHost = &se.config.MaxConnections
}
}
if se.config.HTTPClientSettings.IdleConnTimeout == nil {
defaultIdleConnTimeout := 30 * time.Second
Expand Down
14 changes: 10 additions & 4 deletions exporter/signalfxexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
stability = component.StabilityLevelBeta

defaultHTTPTimeout = time.Second * 5

defaultMaxConns = 100
)

// NewFactory creates a factory for SignalFx exporter.
Expand All @@ -56,17 +58,21 @@ func NewFactory() exporter.Factory {
}

func createDefaultConfig() component.Config {
maxConnCount := defaultMaxConns
return &Config{
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
HTTPClientSettings: confighttp.HTTPClientSettings{Timeout: defaultHTTPTimeout},
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
HTTPClientSettings: confighttp.HTTPClientSettings{
Timeout: defaultHTTPTimeout,
MaxIdleConns: &maxConnCount,
MaxIdleConnsPerHost: &maxConnCount,
},
AccessTokenPassthroughConfig: splunk.AccessTokenPassthroughConfig{
AccessTokenPassthrough: true,
},
DeltaTranslationTTL: 3600,
Correlation: correlation.DefaultConfig(),
NonAlphanumericDimensionChars: "_-.",
MaxConnections: 100,
}
}

Expand Down
3 changes: 2 additions & 1 deletion exporter/signalfxexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ signalfx/allsettings:
access_token: testToken
realm: "us1"
timeout: 2s
max_connections: 70
max_idle_conns: 70
max_idle_conns_per_host: 70
sending_queue:
enabled: true
num_consumers: 2
Expand Down

0 comments on commit 647ce4f

Please sign in to comment.