From ad84f723b1b4d89a5ac4d497e8e4a3f217e72393 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Wed, 31 Jan 2024 22:35:48 -0800 Subject: [PATCH] [extension/awsproxy] awsproxy extension adopts `component.UseLocalHostAsDefaultHost` feature gate --- .chloggen/mx-psi_internal-localhostgate.yaml | 1 + extension/awsproxy/README.md | 3 +++ extension/awsproxy/factory.go | 5 +++-- extension/awsproxy/factory_test.go | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.chloggen/mx-psi_internal-localhostgate.yaml b/.chloggen/mx-psi_internal-localhostgate.yaml index 0b92835d81d2..f571c6f0d9a4 100755 --- a/.chloggen/mx-psi_internal-localhostgate.yaml +++ b/.chloggen/mx-psi_internal-localhostgate.yaml @@ -27,6 +27,7 @@ subtext: | - receiver/influxdb - receiver/zookeeper - receiver/signalfx + - extension/awsproxy # 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. diff --git a/extension/awsproxy/README.md b/extension/awsproxy/README.md index bb58c7803aaa..b6b31428afd3 100644 --- a/extension/awsproxy/README.md +++ b/extension/awsproxy/README.md @@ -42,6 +42,9 @@ The TCP address and port on which this proxy listens for requests. Default: `0.0.0.0:2000` +The `component.UseLocalHostAsDefaultHost` feature gate changes this to localhost:2000. This will become the default in a future release. + + ### proxy_address (Optional) Defines the proxy address that this extension forwards HTTP requests to the AWS backend through. If left unconfigured, requests will be sent directly. This will generally be set to a NAT gateway when the collector is running on a network without public internet. diff --git a/extension/awsproxy/factory.go b/extension/awsproxy/factory.go index 0ce6b02ab76c..c41b575c9576 100644 --- a/extension/awsproxy/factory.go +++ b/extension/awsproxy/factory.go @@ -13,10 +13,11 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/extension/awsproxy/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate" ) const ( - defaultEndpoint = "0.0.0.0:2000" + defaultPort = 2000 ) // NewFactory creates a factory for awsproxy extension. @@ -33,7 +34,7 @@ func createDefaultConfig() component.Config { return &Config{ ProxyConfig: proxy.Config{ TCPAddr: confignet.TCPAddr{ - Endpoint: defaultEndpoint, + Endpoint: localhostgate.EndpointForPort(defaultPort), }, TLSSetting: configtls.TLSClientSetting{ Insecure: false, diff --git a/extension/awsproxy/factory_test.go b/extension/awsproxy/factory_test.go index 24918dc245fa..62ff676c2df9 100644 --- a/extension/awsproxy/factory_test.go +++ b/extension/awsproxy/factory_test.go @@ -28,7 +28,7 @@ func TestFactory_CreateDefaultConfig(t *testing.T) { assert.Equal(t, &Config{ ProxyConfig: proxy.Config{ TCPAddr: confignet.TCPAddr{ - Endpoint: defaultEndpoint, + Endpoint: "0.0.0.0:2000", }, }, }, cfg)