Skip to content

Commit d491a1c

Browse files
atoulmemx-psi
authored andcommitted
[receiver/jaeger] jaegerreceiver adopts component.UseLocalHostAsDefaultHost feature gate (open-telemetry#30980)
Description: jaegerreceiver adopts component.UseLocalHostAsDefaultHost feature gate Link to tracking Issue: open-telemetry#30702 Fixes open-telemetry#30979 Documentation: Updated docs. Co-authored-by: Pablo Baeyens <[email protected]>
1 parent 6a9cbc5 commit d491a1c

File tree

5 files changed

+29
-24
lines changed

5 files changed

+29
-24
lines changed

.chloggen/mx-psi_internal-localhostgate.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ subtext: |
2727
- receiver/influxdb
2828
- receiver/zookeeper
2929
- receiver/signalfx
30+
- receiver/jaeger
3031
- receiver/skywalking
3132
3233
# If your change doesn't affect end users or the exported elements of any package,

receiver/jaegerreceiver/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ object configuration parameter.
3434
- `thrift_compact` (default `endpoint` = 0.0.0.0:6831)
3535
- `thrift_http` (default `endpoint` = 0.0.0.0:14268)
3636

37+
The `component.UseLocalHostAsDefaultHost` feature gate changes these endpoints to localhost:14250, localhost:6832,
38+
localhost:6831 and localhost:14268. This will become the default in a future release.
39+
3740
Examples:
3841

3942
```yaml

receiver/jaegerreceiver/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ func TestLoadConfig(t *testing.T) {
6969
Protocols: Protocols{
7070
GRPC: &configgrpc.GRPCServerSettings{
7171
NetAddr: confignet.NetAddr{
72-
Endpoint: defaultGRPCBindEndpoint,
72+
Endpoint: "0.0.0.0:14250",
7373
Transport: "tcp",
7474
},
7575
},
7676
ThriftHTTP: &confighttp.HTTPServerConfig{
77-
Endpoint: defaultHTTPBindEndpoint,
77+
Endpoint: "0.0.0.0:14268",
7878
},
7979
ThriftCompact: &ProtocolUDP{
80-
Endpoint: defaultThriftCompactBindEndpoint,
80+
Endpoint: "0.0.0.0:6831",
8181
ServerConfigUDP: defaultServerConfigUDP(),
8282
},
8383
ThriftBinary: &ProtocolUDP{
84-
Endpoint: defaultThriftBinaryBindEndpoint,
84+
Endpoint: "0.0.0.0:6832",
8585
ServerConfigUDP: defaultServerConfigUDP(),
8686
},
8787
},
@@ -98,7 +98,7 @@ func TestLoadConfig(t *testing.T) {
9898
},
9999
},
100100
ThriftCompact: &ProtocolUDP{
101-
Endpoint: defaultThriftCompactBindEndpoint,
101+
Endpoint: "0.0.0.0:6831",
102102
ServerConfigUDP: defaultServerConfigUDP(),
103103
},
104104
},

receiver/jaegerreceiver/factory.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"go.opentelemetry.io/collector/receiver"
1919
"go.uber.org/zap"
2020

21+
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
2122
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver/internal/metadata"
2223
)
2324

@@ -28,11 +29,11 @@ const (
2829
protoThriftBinary = "thrift_binary"
2930
protoThriftCompact = "thrift_compact"
3031

31-
// Default endpoints to bind to.
32-
defaultGRPCBindEndpoint = "0.0.0.0:14250"
33-
defaultHTTPBindEndpoint = "0.0.0.0:14268"
34-
defaultThriftCompactBindEndpoint = "0.0.0.0:6831"
35-
defaultThriftBinaryBindEndpoint = "0.0.0.0:6832"
32+
// Default ports to bind to.
33+
defaultGRPCPort = 14250
34+
defaultHTTPPort = 14268
35+
defaultThriftCompactPort = 6831
36+
defaultThriftBinaryPort = 6832
3637
)
3738

3839
var disableJaegerReceiverRemoteSampling = featuregate.GlobalRegistry().MustRegister(
@@ -74,19 +75,19 @@ func createDefaultConfig() component.Config {
7475
Protocols: Protocols{
7576
GRPC: &configgrpc.GRPCServerSettings{
7677
NetAddr: confignet.NetAddr{
77-
Endpoint: defaultGRPCBindEndpoint,
78+
Endpoint: localhostgate.EndpointForPort(defaultGRPCPort),
7879
Transport: "tcp",
7980
},
8081
},
8182
ThriftHTTP: &confighttp.HTTPServerConfig{
82-
Endpoint: defaultHTTPBindEndpoint,
83+
Endpoint: localhostgate.EndpointForPort(defaultHTTPPort),
8384
},
8485
ThriftBinary: &ProtocolUDP{
85-
Endpoint: defaultThriftBinaryBindEndpoint,
86+
Endpoint: localhostgate.EndpointForPort(defaultThriftBinaryPort),
8687
ServerConfigUDP: defaultServerConfigUDP(),
8788
},
8889
ThriftCompact: &ProtocolUDP{
89-
Endpoint: defaultThriftCompactBindEndpoint,
90+
Endpoint: localhostgate.EndpointForPort(defaultThriftCompactPort),
9091
ServerConfigUDP: defaultServerConfigUDP(),
9192
},
9293
},

receiver/jaegerreceiver/factory_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestCreateReceiver(t *testing.T) {
4141
// have to enable at least one protocol for the jaeger receiver to be created
4242
cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
4343
NetAddr: confignet.NetAddr{
44-
Endpoint: defaultGRPCBindEndpoint,
44+
Endpoint: "0.0.0.0:14250",
4545
Transport: "tcp",
4646
},
4747
}
@@ -82,15 +82,15 @@ func TestCreateDefaultGRPCEndpoint(t *testing.T) {
8282

8383
cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
8484
NetAddr: confignet.NetAddr{
85-
Endpoint: defaultGRPCBindEndpoint,
85+
Endpoint: "0.0.0.0:14250",
8686
Transport: "tcp",
8787
},
8888
}
8989
set := receivertest.NewNopCreateSettings()
9090
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)
9191

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

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

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

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

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

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

153153
cfg.(*Config).Protocols.ThriftBinary = &ProtocolUDP{
154-
Endpoint: defaultThriftBinaryBindEndpoint,
154+
Endpoint: "0.0.0.0:6832",
155155
}
156156
set := receivertest.NewNopCreateSettings()
157157
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)
158158

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

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

167167
cfg.(*Config).Protocols.ThriftCompact = &ProtocolUDP{
168-
Endpoint: defaultThriftCompactBindEndpoint,
168+
Endpoint: "0.0.0.0:6831",
169169
}
170170
set := receivertest.NewNopCreateSettings()
171171
r, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil)
172172

173173
assert.NoError(t, err, "unexpected error creating receiver")
174-
assert.Equal(t, defaultThriftCompactBindEndpoint, r.(*jReceiver).config.AgentCompactThrift.Endpoint, "thrift port should be default")
174+
assert.Equal(t, "0.0.0.0:6831", r.(*jReceiver).config.AgentCompactThrift.Endpoint, "thrift port should be default")
175175
}

0 commit comments

Comments
 (0)