From 2d5c0d5492290ed1b68c55161f4ced66b5905b56 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Wed, 20 Dec 2023 20:13:48 -0800 Subject: [PATCH] [extension/httpforwarder] use default http client settings (#29887) **Description:** Use confighttp.HTTPDefaultClientSettings when configuring the HTTPClientSettings for the httpforwarder extension. **Link to tracking Issue:** #6641 --- ...rder_use_default_http_client_settings.yaml | 30 +++++++++++++++++++ extension/httpforwarder/config_test.go | 6 +++- extension/httpforwarder/factory.go | 6 ++-- extension/httpforwarder/testdata/config.yaml | 2 ++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 .chloggen/httpforwarder_use_default_http_client_settings.yaml diff --git a/.chloggen/httpforwarder_use_default_http_client_settings.yaml b/.chloggen/httpforwarder_use_default_http_client_settings.yaml new file mode 100755 index 000000000000..3a67c990620f --- /dev/null +++ b/.chloggen/httpforwarder_use_default_http_client_settings.yaml @@ -0,0 +1,30 @@ +# 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: httpforwarder + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Use confighttp.HTTPDefaultClientSettings when configuring the HTTPClientSettings for the httpforwarder extension. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [6641] + +# (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: | + By default, the HTTP forwarder extension will now use the defaults set in the extension: + * The idle connection timeout is set to 90s. + * The max idle connection count is set to 100. + +# 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: [] diff --git a/extension/httpforwarder/config_test.go b/extension/httpforwarder/config_test.go index f0b47906fcd7..0b01a5ac89f6 100644 --- a/extension/httpforwarder/config_test.go +++ b/extension/httpforwarder/config_test.go @@ -20,6 +20,8 @@ import ( func TestLoadConfig(t *testing.T) { t.Parallel() + maxIdleConns := 42 + idleConnTimeout := 80 * time.Second tests := []struct { id component.ID @@ -40,7 +42,9 @@ func TestLoadConfig(t *testing.T) { Headers: map[string]configopaque.String{ "otel_http_forwarder": "dev", }, - Timeout: 5 * time.Second, + MaxIdleConns: &maxIdleConns, + IdleConnTimeout: &idleConnTimeout, + Timeout: 5 * time.Second, }, }, }, diff --git a/extension/httpforwarder/factory.go b/extension/httpforwarder/factory.go index aa29d7d477ad..4b1649ef5034 100644 --- a/extension/httpforwarder/factory.go +++ b/extension/httpforwarder/factory.go @@ -29,13 +29,13 @@ func NewFactory() extension.Factory { } func createDefaultConfig() component.Config { + httpClientSettings := confighttp.NewDefaultHTTPClientSettings() + httpClientSettings.Timeout = 10 * time.Second return &Config{ Ingress: confighttp.HTTPServerSettings{ Endpoint: defaultEndpoint, }, - Egress: confighttp.HTTPClientSettings{ - Timeout: 10 * time.Second, - }, + Egress: httpClientSettings, } } diff --git a/extension/httpforwarder/testdata/config.yaml b/extension/httpforwarder/testdata/config.yaml index 1501cdd95903..2d6e17e95d9a 100644 --- a/extension/httpforwarder/testdata/config.yaml +++ b/extension/httpforwarder/testdata/config.yaml @@ -6,4 +6,6 @@ http_forwarder/1: endpoint: http://target/ headers: otel_http_forwarder: dev + idle_conn_timeout: 80s + max_idle_conns: 42 timeout: 5s