Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[all] Add support for component.UseLocalHostAsDefaultHost #27439

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f3f5dfe
make for-all CMD="go mod edit -replace go.opentelemetry.io/collector/…
mx-psi Oct 4, 2023
eaedf9d
[receiver/jmx] Support component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
8bef435
[extension/awsproxy] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
1d45966
[receiver/loki] Add support component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
8b99cb0
[receiver/jaeger] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
938cb18
[receiver/zipkin] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
10a11d8
[receiver/awsxray] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 4, 2023
674edef
[receiver/influxdbreceiver] Add support for component.UseLocalHostAsD…
mx-psi Oct 4, 2023
76e6363
[receiver/awsfirehose] Add support for component.UseLocalHostAsDefaul…
mx-psi Oct 4, 2023
b05009e
[receiver/opencensus] Add support for component.UseLocalHostAsDefault…
mx-psi Oct 4, 2023
828ed19
[receiver/skywalking] Add support for component.UseLocalHostAsDefault…
mx-psi Oct 4, 2023
4e6d80f
[extension/jaegerrremotesampling] Add support for component.UseLocalH…
mx-psi Oct 5, 2023
f4bb07e
[receiver/zookeeper] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 5, 2023
e0a8c20
[extension/httpforwarder] Add support for component.UseLocalHostAsDef…
mx-psi Oct 5, 2023
5f2228e
[processor/remoteobserver] Add support for component.LocalHostAsDefau…
mx-psi Oct 5, 2023
5e7c11b
[receiver/sapm] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 5, 2023
73a1588
[receiver/signalfx] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 5, 2023
77c331a
[receiver/splunkhec] Add support for component.UseLocalHostAsDefaultHost
mx-psi Oct 5, 2023
a41b2f5
Add changelog entry
mx-psi Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[receiver/jaeger] Add support for component.UseLocalHostAsDefaultHost
mx-psi committed Oct 5, 2023
commit 8b99cb0f8846476b6189cc146b88734bd8d67399
2 changes: 2 additions & 0 deletions receiver/jaegerreceiver/README.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ object configuration parameter.
- `thrift_compact` (default `endpoint` = 0.0.0.0:6831)
- `thrift_http` (default `endpoint` = 0.0.0.0:14268)

The `component.UseLocalHostAsDefaultHost` feature gate changes the defaults to use `localhost` instead of `0.0.0.0`.

Examples:

```yaml
10 changes: 5 additions & 5 deletions receiver/jaegerreceiver/config_test.go
Original file line number Diff line number Diff line change
@@ -69,19 +69,19 @@ func TestLoadConfig(t *testing.T) {
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:14250",
Transport: "tcp",
},
},
ThriftHTTP: &confighttp.HTTPServerSettings{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: "0.0.0.0:14268",
},
ThriftCompact: &ProtocolUDP{
Endpoint: defaultThriftCompactBindEndpoint,
Endpoint: "0.0.0.0:6831",
ServerConfigUDP: defaultServerConfigUDP(),
},
ThriftBinary: &ProtocolUDP{
Endpoint: defaultThriftBinaryBindEndpoint,
Endpoint: "0.0.0.0:6832",
ServerConfigUDP: defaultServerConfigUDP(),
},
},
@@ -98,7 +98,7 @@ func TestLoadConfig(t *testing.T) {
},
},
ThriftCompact: &ProtocolUDP{
Endpoint: defaultThriftCompactBindEndpoint,
Endpoint: "0.0.0.0:6831",
ServerConfigUDP: defaultServerConfigUDP(),
},
},
17 changes: 8 additions & 9 deletions receiver/jaegerreceiver/factory.go
Original file line number Diff line number Diff line change
@@ -29,11 +29,10 @@ const (
protoThriftBinary = "thrift_binary"
protoThriftCompact = "thrift_compact"

// Default endpoints to bind to.
defaultGRPCBindEndpoint = "0.0.0.0:14250"
defaultHTTPBindEndpoint = "0.0.0.0:14268"
defaultThriftCompactBindEndpoint = "0.0.0.0:6831"
defaultThriftBinaryBindEndpoint = "0.0.0.0:6832"
grpcPort = 14250
httpPort = 14268
thriftCompactPort = 6831
thriftBinaryPort = 6832
)

var disableJaegerReceiverRemoteSampling = featuregate.GlobalRegistry().MustRegister(
@@ -78,19 +77,19 @@ func createDefaultConfig() component.Config {
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: component.EndpointForPort(grpcPort),
Transport: "tcp",
},
},
ThriftHTTP: &confighttp.HTTPServerSettings{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: component.EndpointForPort(httpPort),
},
ThriftBinary: &ProtocolUDP{
Endpoint: defaultThriftBinaryBindEndpoint,
Endpoint: component.EndpointForPort(thriftBinaryPort),
ServerConfigUDP: defaultServerConfigUDP(),
},
ThriftCompact: &ProtocolUDP{
Endpoint: defaultThriftCompactBindEndpoint,
Endpoint: component.EndpointForPort(thriftCompactPort),
ServerConfigUDP: defaultServerConfigUDP(),
},
},
20 changes: 10 additions & 10 deletions receiver/jaegerreceiver/factory_test.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ func TestCreateReceiver(t *testing.T) {
// have to enable at least one protocol for the jaeger receiver to be created
cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:14250",
Transport: "tcp",
},
}
@@ -82,15 +82,15 @@ func TestCreateDefaultGRPCEndpoint(t *testing.T) {

cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:14250",
Transport: "tcp",
},
}
set := receivertest.NewNopCreateSettings()
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)

assert.NoError(t, err, "unexpected error creating receiver")
assert.Equal(t, defaultGRPCBindEndpoint, r.(*jReceiver).config.CollectorGRPCServerSettings.NetAddr.Endpoint, "grpc port should be default")
assert.Equal(t, "0.0.0.0:14250", r.(*jReceiver).config.CollectorGRPCServerSettings.NetAddr.Endpoint, "grpc port should be default")
}

func TestCreateTLSGPRCEndpoint(t *testing.T) {
@@ -99,7 +99,7 @@ func TestCreateTLSGPRCEndpoint(t *testing.T) {

cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:14250",
Transport: "tcp",
},
TLSSetting: &configtls.TLSServerSetting{
@@ -120,7 +120,7 @@ func TestCreateTLSThriftHTTPEndpoint(t *testing.T) {
cfg := factory.CreateDefaultConfig()

cfg.(*Config).Protocols.ThriftHTTP = &confighttp.HTTPServerSettings{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: "0.0.0.0:14268",
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
CertFile: "./testdata/server.crt",
@@ -143,33 +143,33 @@ func TestCreateInvalidHTTPEndpoint(t *testing.T) {
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)

assert.NoError(t, err, "unexpected error creating receiver")
assert.Equal(t, defaultHTTPBindEndpoint, r.(*jReceiver).config.CollectorHTTPSettings.Endpoint, "http port should be default")
assert.Equal(t, "0.0.0.0:14268", r.(*jReceiver).config.CollectorHTTPSettings.Endpoint, "http port should be default")
}

func TestCreateInvalidThriftBinaryEndpoint(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

cfg.(*Config).Protocols.ThriftBinary = &ProtocolUDP{
Endpoint: defaultThriftBinaryBindEndpoint,
Endpoint: "0.0.0.0:6832",
}
set := receivertest.NewNopCreateSettings()
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)

assert.NoError(t, err, "unexpected error creating receiver")
assert.Equal(t, defaultThriftBinaryBindEndpoint, r.(*jReceiver).config.AgentBinaryThrift.Endpoint, "thrift port should be default")
assert.Equal(t, "0.0.0.0:6832", r.(*jReceiver).config.AgentBinaryThrift.Endpoint, "thrift port should be default")
}

func TestCreateInvalidThriftCompactEndpoint(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

cfg.(*Config).Protocols.ThriftCompact = &ProtocolUDP{
Endpoint: defaultThriftCompactBindEndpoint,
Endpoint: "0.0.0.0:6831",
}
set := receivertest.NewNopCreateSettings()
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)

assert.NoError(t, err, "unexpected error creating receiver")
assert.Equal(t, defaultThriftCompactBindEndpoint, r.(*jReceiver).config.AgentCompactThrift.Endpoint, "thrift port should be default")
assert.Equal(t, "0.0.0.0:6831", r.(*jReceiver).config.AgentCompactThrift.Endpoint, "thrift port should be default")
}
6 changes: 6 additions & 0 deletions receiver/jaegerreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
@@ -39,6 +39,9 @@ import (
jaegertranslator "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger"
)

// onceLogLocalHost is used to log the info log about changing the default once.
var onceLogLocalHost sync.Once

// configuration defines the behavior and the ports that
// the Jaeger receiver will use.
type configuration struct {
@@ -125,6 +128,9 @@ func newJaegerReceiver(
}

func (jr *jReceiver) Start(_ context.Context, host component.Host) error {
onceLogLocalHost.Do(func() {
component.LogAboutUseLocalHostAsDefault(jr.settings.Logger)
})
if err := jr.startAgent(host); err != nil {
return err
}