From b60fbd5241939c3e66b927e7f2441e627881e0b9 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Thu, 1 Feb 2024 02:06:28 -0800 Subject: [PATCH] [extension/jaegerremotesampling] jaegerremotesampling adopts `component.UseLocalHostAsDefaultHost` feature gate (#30983) Description: jaegerremotesampling extension adopts component.UseLocalHostAsDefaultHost feature gate Link to tracking Issue: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30702 Fixes https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30982 Documentation: Updated docs. Co-authored-by: Pablo Baeyens --- .chloggen/mx-psi_internal-localhostgate.yaml | 1 + extension/jaegerremotesampling/README.md | 7 +++++-- extension/jaegerremotesampling/config_test.go | 8 ++++---- extension/jaegerremotesampling/factory.go | 5 +++-- extension/jaegerremotesampling/factory_test.go | 4 ++-- extension/jaegerremotesampling/go.mod | 3 +++ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.chloggen/mx-psi_internal-localhostgate.yaml b/.chloggen/mx-psi_internal-localhostgate.yaml index 038439f6d29a..9ac87b0988db 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/jaegerremotesampling - receiver/jaeger - receiver/skywalking diff --git a/extension/jaegerremotesampling/README.md b/extension/jaegerremotesampling/README.md index d89f5d4cf4e1..1b4049f4e246 100644 --- a/extension/jaegerremotesampling/README.md +++ b/extension/jaegerremotesampling/README.md @@ -17,8 +17,11 @@ This extension allows serving sampling strategies following the Jaeger's remote sampling API. This extension can be configured to proxy requests to a backing remote sampling server, which could potentially be a Jaeger Collector down the pipeline, or a static JSON file from the local file system. By default, two listeners are made available: -- `localhost:5778`, following the legacy remote sampling endpoint as defined by Jaeger -- `localhost:14250`, following the gRPC remote sampling endpoint, also defined by Jaeger +- `0.0.0.0:5778`, following the legacy remote sampling endpoint as defined by Jaeger +- `0.0.0.0:14250`, following the gRPC remote sampling endpoint, also defined by Jaeger + +The `component.UseLocalHostAsDefaultHost` feature gate changes this to localhost:9943. This will become the default in a future release. + Note that the port `14250` will clash with the Jaeger Receiver. When both are used, it's recommended to change this extension to use another port. diff --git a/extension/jaegerremotesampling/config_test.go b/extension/jaegerremotesampling/config_test.go index 5b877252e23c..43174721268e 100644 --- a/extension/jaegerremotesampling/config_test.go +++ b/extension/jaegerremotesampling/config_test.go @@ -29,9 +29,9 @@ func TestLoadConfig(t *testing.T) { { id: component.NewID(metadata.Type), expected: &Config{ - HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: ":5778"}, + HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: "0.0.0.0:5778"}, GRPCServerSettings: &configgrpc.GRPCServerSettings{NetAddr: confignet.NetAddr{ - Endpoint: ":14250", + Endpoint: "0.0.0.0:14250", Transport: "tcp", }}, Source: Source{ @@ -44,9 +44,9 @@ func TestLoadConfig(t *testing.T) { { id: component.NewIDWithName(metadata.Type, "1"), expected: &Config{ - HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: ":5778"}, + HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: "0.0.0.0:5778"}, GRPCServerSettings: &configgrpc.GRPCServerSettings{NetAddr: confignet.NetAddr{ - Endpoint: ":14250", + Endpoint: "0.0.0.0:14250", Transport: "tcp", }}, Source: Source{ diff --git a/extension/jaegerremotesampling/factory.go b/extension/jaegerremotesampling/factory.go index bfa15fcbeee8..9123dee0e1de 100644 --- a/extension/jaegerremotesampling/factory.go +++ b/extension/jaegerremotesampling/factory.go @@ -16,6 +16,7 @@ import ( "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/metadata" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate" ) // NewFactory creates a factory for the jaeger remote sampling extension. @@ -31,11 +32,11 @@ func NewFactory() extension.Factory { func createDefaultConfig() component.Config { return &Config{ HTTPServerConfig: &confighttp.HTTPServerConfig{ - Endpoint: ":5778", + Endpoint: localhostgate.EndpointForPort(5778), }, GRPCServerSettings: &configgrpc.GRPCServerSettings{ NetAddr: confignet.NetAddr{ - Endpoint: ":14250", + Endpoint: localhostgate.EndpointForPort(14250), Transport: "tcp", }, }, diff --git a/extension/jaegerremotesampling/factory_test.go b/extension/jaegerremotesampling/factory_test.go index d0ceac8408b2..e8fb9c0484d6 100644 --- a/extension/jaegerremotesampling/factory_test.go +++ b/extension/jaegerremotesampling/factory_test.go @@ -18,9 +18,9 @@ import ( func TestCreateDefaultConfig(t *testing.T) { // prepare and test expected := &Config{ - HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: ":5778"}, + HTTPServerConfig: &confighttp.HTTPServerConfig{Endpoint: "0.0.0.0:5778"}, GRPCServerSettings: &configgrpc.GRPCServerSettings{NetAddr: confignet.NetAddr{ - Endpoint: ":14250", + Endpoint: "0.0.0.0:14250", Transport: "tcp", }}, } diff --git a/extension/jaegerremotesampling/go.mod b/extension/jaegerremotesampling/go.mod index 7a0835b42f3d..aec7ffa5532c 100644 --- a/extension/jaegerremotesampling/go.mod +++ b/extension/jaegerremotesampling/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( github.com/fortytw2/leaktest v1.3.0 github.com/jaegertracing/jaeger v1.53.0 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.93.0 github.com/stretchr/testify v1.8.4 github.com/tilinna/clock v1.1.0 go.opentelemetry.io/collector/component v0.93.1-0.20240130182548-89388addcc7f @@ -90,3 +91,5 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common