From cfe22a0eeb55ae7e16ee5ebe37185b0eb32c61ad Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 31 Jan 2024 13:17:01 +0000 Subject: [PATCH] [receiver/awsxray] Use component.UseLocalHostAsDefaultHost feature gate (#30824) **Description:** Fixes #30823 --- .chloggen/mx-psi_internal-localhostgate.yaml | 1 + receiver/awsxrayreceiver/README.md | 2 ++ receiver/awsxrayreceiver/factory.go | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.chloggen/mx-psi_internal-localhostgate.yaml b/.chloggen/mx-psi_internal-localhostgate.yaml index 588843e59f4d..cec1e3451f9a 100755 --- a/.chloggen/mx-psi_internal-localhostgate.yaml +++ b/.chloggen/mx-psi_internal-localhostgate.yaml @@ -23,6 +23,7 @@ subtext: | - receiver/awsfirehose - processor/remotetap - receiver/splunk_hec + - receiver/awsxray # 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/receiver/awsxrayreceiver/README.md b/receiver/awsxrayreceiver/README.md index 2af8c5415e5e..36bad83c942f 100644 --- a/receiver/awsxrayreceiver/README.md +++ b/receiver/awsxrayreceiver/README.md @@ -48,6 +48,8 @@ The UDP address and port on which this receiver listens for X-Ray segment docume 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. + ### transport (Optional) This should always be "udp" as X-Ray SDKs only send segments using UDP. diff --git a/receiver/awsxrayreceiver/factory.go b/receiver/awsxrayreceiver/factory.go index ee1f1328508b..528b2b7e4609 100644 --- a/receiver/awsxrayreceiver/factory.go +++ b/receiver/awsxrayreceiver/factory.go @@ -12,10 +12,13 @@ import ( "go.opentelemetry.io/collector/receiver" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver/internal/udppoller" ) +const defaultPort = 2000 + // NewFactory creates a factory for AWS receiver. func NewFactory() receiver.Factory { return receiver.NewFactory( @@ -29,10 +32,8 @@ func createDefaultConfig() component.Config { // in the X-Ray daemon: // https://github.com/aws/aws-xray-daemon/blob/master/pkg/cfg/cfg.go#L99 return &Config{ - // X-Ray daemon defaults to 127.0.0.1:2000 but - // the default in OT is 0.0.0.0. NetAddr: confignet.NetAddr{ - Endpoint: "0.0.0.0:2000", + Endpoint: localhostgate.EndpointForPort(defaultPort), Transport: udppoller.Transport, }, ProxyServer: proxy.DefaultConfig(),